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 }