aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-10 03:16:44 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-10 03:16:44 +0300
commit6d7fb5bee4e61d44fb30f5b9d15e6255268c59d6 (patch)
tree0c704a346b2fceb5070b1e74f9bf4d62315e750e
parentbf00e9862888cf60a427cdb611352fc75bb1c912 (diff)
Add /silent command to send messages without sound
-rw-r--r--telegram/commands.go23
1 files changed, 23 insertions, 0 deletions
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 {