Files
telegram-bot/modules/UrlLimitations/UserJoinHandler.cs
T
2023-07-29 15:14:52 +03:00

28 lines
771 B
C#

using System;
using System.Threading.Tasks;
using BotFramework;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions;
namespace Kruzya.TelegramBot.UrlLimitations;
public class UserJoinHandler : BotEventHandler
{
protected readonly CoreContext dbCtx;
public UserJoinHandler(CoreContext coreContext)
{
dbCtx = coreContext;
}
[InChat(InChat.Public)]
[Message(MessageFlag.HasNewChatMembers)]
public async Task OnChatMembersAdded()
{
foreach (var member in RawUpdate.Message.NewChatMembers)
await dbCtx.UserValues.SetOptionValue<UInt16>(Chat.Id, member.Id, "urlLimitations.messagesAfterJoin",
0);
}
}