From fe7346a530c8ac985f2a4a9edeeecc134f320a2f Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Tue, 8 Feb 2022 15:22:11 -0500 Subject: [PATCH] Add /ttl command to set time-to-live of messages in secret chats --- telegram/commands.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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)"}, @@ -739,6 +740,24 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) } err = c.unsubscribe(chatID) + 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 }