mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[core] move message auto-delete service from code-watcher to core
This commit is contained in:
@@ -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
|
||||||
{
|
{
|
||||||
@@ -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,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>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user