UTM for links on posts

This commit is contained in:
2020-03-04 11:55:10 +04:00
parent 8f8898e901
commit 768a0d064f
5 changed files with 79 additions and 9 deletions
+7 -7
View File
@@ -24,10 +24,8 @@ namespace Kruzya.TelegramBot.UrlLimitations
}
[TextMessage(InChat.Public)]
public async Task OnMessageReceived()
public void OnMessageReceived()
{
Logger.LogDebug($"Message received from {From.Id} in {Chat.Id}");
UInt16 messageCount;
var chatMember = ChatMember.From(Chat.Id, From.Id);
if (!ChatMembersCache.TryGetValue(chatMember, out messageCount))
@@ -48,10 +46,12 @@ namespace Kruzya.TelegramBot.UrlLimitations
0)
{
var targetChat = new ChatId(Chat.Id);
await Bot.KickChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1));
await Bot.DeleteMessageAsync(targetChat, message.MessageId);
await Bot.SendTextMessageAsync(targetChat,
$"Member {From.ToHtml()} has been banned.\n<b>Reason</b>: <pre>Spam suspicion</pre>", ParseMode.Html);
Task.WaitAll(new Task[] {
Bot.KickChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1)),
Bot.DeleteMessageAsync(targetChat, message.MessageId),
Bot.SendTextMessageAsync(targetChat,
$"Member {From.ToHtml()} has been banned.\n<b>Reason</b>: <pre>Spam suspicion</pre>", ParseMode.Html)
});
}
}
}