[core] move core handlers into subfolder

This commit is contained in:
Andriy
2023-07-20 21:22:35 +03:00
parent 8de8eac959
commit 467ccd4fde
10 changed files with 17 additions and 17 deletions
@@ -9,7 +9,7 @@ using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace Kruzya.TelegramBot.Core
namespace Kruzya.TelegramBot.Core.Handler
{
public abstract class CommonHandler : BotEventHandler
{
@@ -18,7 +18,7 @@ namespace Kruzya.TelegramBot.Core
protected Message? Message => RawUpdate.Message;
protected User? RepliedUser => Message?.ReplyToMessage?.From;
protected CommonHandler(CoreContext db)
{
Db = db;
@@ -34,8 +34,8 @@ namespace Kruzya.TelegramBot.Core
{
return RepliedUser != null && await Bot.CanPunishMember(Chat, From, RepliedUser);
}
protected async Task BanMember(long userId, DateTime banEnd)
{
await Bot.RestrictChatMemberAsync(
@@ -48,7 +48,7 @@ namespace Kruzya.TelegramBot.Core
banEnd
);
}
protected async Task<BotUserValue> GetWarnOption(User user)
{
return await Db.UserValues.FindOrCreateOption(Chat.Id, user.Id, "warnCount");
@@ -1,14 +1,12 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using BotFramework;
using BotFramework.Attributes;
using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core
namespace Kruzya.TelegramBot.Core.Handler
{
public class GeneralHandler : BotEventHandler
{
@@ -22,7 +20,7 @@ namespace Kruzya.TelegramBot.Core
}
protected readonly CoreContext databaseContext;
public GeneralHandler(CoreContext dbCtx)
{
databaseContext = dbCtx;
@@ -32,7 +30,7 @@ namespace Kruzya.TelegramBot.Core
[Priority(short.MaxValue - 10)]
public async Task<bool> Listener()
{
foreach (var message in new Message[] {RawUpdate.Message, RawUpdate.EditedMessage, RawUpdate.ChannelPost, RawUpdate.EditedChannelPost})
foreach (var message in new Message[] { RawUpdate.Message, RawUpdate.EditedMessage, RawUpdate.ChannelPost, RawUpdate.EditedChannelPost })
{
if (message == null)
{