Add /silent command to send messages without sound

This commit is contained in:
Bohdan Horbeshko 2022-02-09 19:16:44 -05:00
parent bf00e98628
commit 6d7fb5bee4

View file

@ -56,6 +56,7 @@ var transportCommands = map[string]command{
var chatCommands = map[string]command{ var chatCommands = map[string]command{
"d": command{"[n]", "delete your last message(s)"}, "d": command{"[n]", "delete your last message(s)"},
"s": command{"edited message", "edit your last message"}, "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"}, "add": command{"@username", "add @username to your chat list"},
"join": command{"https://t.me/invite_link", "join to chat via invite link"}, "join": command{"https://t.me/invite_link", "join to chat via invite link"},
"group": command{"title", "create groupchat «title» with current user"}, "group": command{"title", "create groupchat «title» with current user"},
@ -448,6 +449,28 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
} else { } else {
return "Message processing error", true 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 // add @contact
case "add": case "add":
if len(args) < 1 { if len(args) < 1 {