[core] move message auto-delete service from code-watcher to core

This commit is contained in:
Andriy
2023-01-23 13:12:38 +02:00
parent 261c1178b7
commit bbcdfff2b9
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 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 BotFramework.Abstractions;
using Kruzya.TelegramBot.Core.Service; using Kruzya.TelegramBot.Core.Service;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Exceptions; using Telegram.Bot.Exceptions;
namespace West.TelegramBot.CodeWatcher; namespace Kruzya.TelegramBot.Core.AutoDelete;
public class DeleteService : AbstractTimedHostedService public class DeleteService : AbstractTimedHostedService
{ {
+6
View File
@@ -1,4 +1,5 @@
using BotFramework; using BotFramework;
using Kruzya.TelegramBot.Core.AutoDelete;
using Kruzya.TelegramBot.Core.Cache; using Kruzya.TelegramBot.Core.Cache;
using Kruzya.TelegramBot.Core.Data; using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions; using Kruzya.TelegramBot.Core.Extensions;
@@ -9,6 +10,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Collections.Concurrent;
using Telegram.Bot.Types; using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core namespace Kruzya.TelegramBot.Core
@@ -47,6 +49,10 @@ namespace Kruzya.TelegramBot.Core
services.AddSingleton<ThreadSafeRandom>(); services.AddSingleton<ThreadSafeRandom>();
services.AddSingleton<ConcurrentBag<DeleteRequest>>();
services.AddHostedService<DeleteService>();
// Trigger module handlers. // Trigger module handlers.
_core.Modules.ConfigureServices(services); _core.Modules.ConfigureServices(services);
} }
+1 -9
View File
@@ -1,17 +1,9 @@
using System.Collections.Concurrent; using Kruzya.TelegramBot.Core;
using Kruzya.TelegramBot.Core;
using Microsoft.Extensions.DependencyInjection;
namespace West.TelegramBot.CodeWatcher namespace West.TelegramBot.CodeWatcher
{ {
public class CodeWatcher : Module public class CodeWatcher : Module
{ {
public CodeWatcher(Core core) : base(core) {} 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;
using BotFramework.Attributes; using BotFramework.Attributes;
using BotFramework.Enums; using BotFramework.Enums;
using Kruzya.TelegramBot.Core.AutoDelete;
using Kruzya.TelegramBot.Core.Extensions; using Kruzya.TelegramBot.Core.Extensions;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;