aboutsummaryrefslogtreecommitdiff
path: root/telegram
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-08 23:22:11 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-08 23:22:11 +0300
commitfe7346a530c8ac985f2a4a9edeeecc134f320a2f (patch)
treef91c799b7b8f4f672632775ca65b70f8625502aa /telegram
parent2a5af5a2647f5965af6a3375d0206581727c70cd (diff)
Add /ttl command to set time-to-live of messages in secret chats
Diffstat (limited to 'telegram')
-rw-r--r--telegram/commands.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index 2847ceb..7f97a6c 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -75,6 +75,7 @@ var chatCommands = map[string]command{
"promote": command{"id or @username [title]", "promote user to admin in current chat"},
"leave": command{"", "leave current chat"},
"leave!": command{"", "leave current chat (for owners)"},
+ "ttl": command{"", "set secret chat messages TTL before self-destroying (in seconds)"},
"close": command{"", "close current secret chat"},
"delete": command{"", "delete current chat from chat list"},
"members": command{"[query]", "search members [by optional query] in current chat (requires admin rights)"},
@@ -742,6 +743,24 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
+ // set TTL
+ case "ttl":
+ var ttl int64
+ var err error
+ if len(args) > 0 {
+ ttl, err = strconv.ParseInt(args[0], 10, 32)
+ if err != nil {
+ return "Invalid TTL", true
+ }
+ }
+ _, err = c.client.SetChatMessageTtl(&client.SetChatMessageTtlRequest{
+ ChatId: chatID,
+ Ttl: int32(ttl),
+ })
+
+ if err != nil {
+ return err.Error(), true
+ }
// close secret chat
case "close":
chat, _, err := c.GetContactByID(chatID, nil)