2020-03-03 14:11:51 +04:00
|
|
|
using System;
|
2020-03-08 12:38:00 +04:00
|
|
|
using System.Threading.Tasks;
|
2020-03-03 14:11:51 +04:00
|
|
|
using BotFramework;
|
|
|
|
|
using BotFramework.Attributes;
|
2021-12-25 15:17:13 +02:00
|
|
|
using BotFramework.Enums;
|
2020-03-08 12:38:00 +04:00
|
|
|
using Kruzya.TelegramBot.Core.Data;
|
|
|
|
|
using Kruzya.TelegramBot.Core.Extensions;
|
2020-03-03 14:11:51 +04:00
|
|
|
|
|
|
|
|
namespace Kruzya.TelegramBot.UrlLimitations
|
|
|
|
|
{
|
|
|
|
|
public class UserJoinHandler : BotEventHandler
|
|
|
|
|
{
|
2020-03-08 12:38:00 +04:00
|
|
|
protected readonly CoreContext dbCtx;
|
2020-03-03 14:11:51 +04:00
|
|
|
|
2020-03-08 12:38:00 +04:00
|
|
|
public UserJoinHandler(CoreContext coreContext)
|
2020-03-03 14:11:51 +04:00
|
|
|
{
|
2020-03-08 12:38:00 +04:00
|
|
|
dbCtx = coreContext;
|
2020-03-03 14:11:51 +04:00
|
|
|
}
|
2023-07-29 01:50:28 +03:00
|
|
|
|
|
|
|
|
[InChat(InChat.Public)]
|
|
|
|
|
[Message(MessageFlag.HasNewChatMembers)]
|
2020-03-08 12:38:00 +04:00
|
|
|
public async Task OnChatMembersAdded()
|
2020-03-03 14:11:51 +04:00
|
|
|
{
|
2020-03-08 12:38:00 +04:00
|
|
|
foreach (var member in RawUpdate.Message.NewChatMembers)
|
|
|
|
|
await dbCtx.UserValues.SetOptionValue<UInt16>(Chat.Id, member.Id, "urlLimitations.messagesAfterJoin",
|
|
|
|
|
0);
|
2020-03-03 14:11:51 +04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|