From 6b26effc29e23e77333d4697faab1bc6f99319d3 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 9 Jan 2023 15:08:10 +0100 Subject: [PATCH] Ignore unknown slash commands in groups not explicitly directed at us --- Program.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Program.cs b/Program.cs index aead7af..e5c4e2d 100644 --- a/Program.cs +++ b/Program.cs @@ -72,6 +72,9 @@ async Task BotOnMessageReceived(ITelegramBotClient botClient, Message message) { command = firstword.Replace($"@{me.Username}", "").TrimStart('/'); // remove command (and optional username) from message text query = message.Text?[firstword.Length..]; + // ignore unknown slash commands in groups not explicitly directed at us + if (!iBotCommands.Contains(command) && message.Chat.Type != ChatType.Private && !firstword.Contains($"@{me.Username}")) + return; } else { // are we sure the bot is being asked?