Skip to content

Commit

Permalink
Add link to chat where spam was detected
Browse files Browse the repository at this point in the history
  • Loading branch information
TiraelSedai committed Jun 24, 2024
1 parent 1b7763c commit 5bf3258
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ClubDoorman/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,34 @@ private async Task DeleteAndReportMessage(Message message, User user, string rea
);
await _bot.DeleteMessageAsync(message.Chat.Id, message.MessageId, cancellationToken: stoppingToken);

var cbd = $"ban_{message.Chat.Id}_{user.Id}";
var callbackData = $"ban_{message.Chat.Id}_{user.Id}";
var postLink = LinkToMessage(message.Chat, message.MessageId);

await _bot.SendTextMessageAsync(
new ChatId(Config.AdminChatId),
$"{reason}, сообщение удалено.{Environment.NewLine}Юзер {user.FirstName} {user.LastName}; Чат {message.Chat.Title}",
$"{reason}, сообщение удалено.{Environment.NewLine}Юзер {user.FirstName} {user.LastName}; Чат {message.Chat.Title}{Environment.NewLine}{postLink}",
replyToMessageId: forward.MessageId,
replyMarkup: new InlineKeyboardMarkup(
[new InlineKeyboardButton("🤖 ban") { CallbackData = cbd }, new InlineKeyboardButton("👍 ok") { CallbackData = "noop" }]
[
new InlineKeyboardButton("🤖 ban") { CallbackData = callbackData },
new InlineKeyboardButton("👍 ok") { CallbackData = "noop" }
]
),
cancellationToken: stoppingToken
);
}

private static string LinkToMessage(Chat chat, long messageId) =>
chat.Type == ChatType.Supergroup
? LinkToSuperGroupMessage(chat, messageId)
: chat.Username == null
? ""
: LinkToGroupWithNameMessage(chat, messageId);

private static string LinkToSuperGroupMessage(Chat chat, long messageId) => $"https://t.me/c/{chat.Id.ToString()[4..]}/{messageId}";

private static string LinkToGroupWithNameMessage(Chat chat, long messageId) => $"https://t.me/{chat.Username}/{messageId}";

private async Task AdminChatMessage(Message message)
{
if (message is { ReplyToMessage: not null, Text: "/spam" or "/ham" or "/classify" or "/lookalike" })
Expand Down

0 comments on commit 5bf3258

Please sign in to comment.