From 6d7fb5bee4e61d44fb30f5b9d15e6255268c59d6 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Wed, 9 Feb 2022 19:16:44 -0500 Subject: [PATCH] Add /silent command to send messages without sound --- telegram/commands.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/telegram/commands.go b/telegram/commands.go index 44d9df8..74c2cfa 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -56,6 +56,7 @@ var transportCommands = map[string]command{ var chatCommands = map[string]command{ "d": command{"[n]", "delete your last message(s)"}, "s": command{"edited message", "edit your last message"}, + "silent": command{"message", "send a message without sound"}, "add": command{"@username", "add @username to your chat list"}, "join": command{"https://t.me/invite_link", "join to chat via invite link"}, "group": command{"title", "create groupchat «title» with current user"}, @@ -448,6 +449,28 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) } else { return "Message processing error", true } + // send without sound + case "silent": + if len(args) < 1 { + return "Not enough arguments", true + } + + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "") + + if content != nil { + _, err := c.client.SendMessage(&client.SendMessageRequest{ + ChatId: chatID, + InputMessageContent: content, + Options: &client.MessageSendOptions{ + DisableNotification: true, + }, + }) + if err != nil { + return err.Error(), true + } + } else { + return "Message processing error", true + } // add @contact case "add": if len(args) < 1 {