Merge pull request #29 from Bubuni-Team/feature/core/auto-delete

Move message auto-delete service from code-watcher to core
This commit is contained in:
2023-01-28 23:15:11 +03:00
committed by GitHub
5 changed files with 16 additions and 13 deletions
@@ -1,6 +1,7 @@
using Telegram.Bot.Types;
using System;
using Telegram.Bot.Types;
namespace West.TelegramBot.CodeWatcher;
namespace Kruzya.TelegramBot.Core.AutoDelete;
public class DeleteRequest
{
@@ -1,11 +1,14 @@
using System.Collections.Concurrent;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using BotFramework.Abstractions;
using Kruzya.TelegramBot.Core.Service;
using Microsoft.Extensions.Logging;
using Telegram.Bot;
using Telegram.Bot.Exceptions;
namespace West.TelegramBot.CodeWatcher;
namespace Kruzya.TelegramBot.Core.AutoDelete;
public class DeleteService : AbstractTimedHostedService
{
+6
View File
@@ -1,4 +1,5 @@
using BotFramework;
using Kruzya.TelegramBot.Core.AutoDelete;
using Kruzya.TelegramBot.Core.Cache;
using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions;
@@ -9,6 +10,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.Collections.Concurrent;
using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core
@@ -47,6 +49,10 @@ namespace Kruzya.TelegramBot.Core
services.AddSingleton<ThreadSafeRandom>();
services.AddSingleton<ConcurrentBag<DeleteRequest>>();
services.AddHostedService<DeleteService>();
// Trigger module handlers.
_core.Modules.ConfigureServices(services);
}
+1 -9
View File
@@ -1,17 +1,9 @@
using System.Collections.Concurrent;
using Kruzya.TelegramBot.Core;
using Microsoft.Extensions.DependencyInjection;
using Kruzya.TelegramBot.Core;
namespace West.TelegramBot.CodeWatcher
{
public class CodeWatcher : Module
{
public CodeWatcher(Core core) : base(core) {}
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ConcurrentBag<DeleteRequest>>();
services.AddHostedService<DeleteService>();
}
}
}
+1
View File
@@ -2,6 +2,7 @@
using BotFramework;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core.AutoDelete;
using Kruzya.TelegramBot.Core.Extensions;
using Telegram.Bot;
using Telegram.Bot.Types;