Add /close command
This commit is contained in:
parent
49423147e3
commit
4df1643312
|
@ -47,7 +47,7 @@ var chatCommands = map[string]command{
|
|||
"kick": command{"id or @username", "remove user to current chat"},
|
||||
"ban": command{"id or @username [hours]", "restrict @username from current chat for [hours] or forever"},
|
||||
"leave": command{"", "leave current chat"},
|
||||
//"close": command{"", "close current secret chat"},
|
||||
"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)"},
|
||||
}
|
||||
|
@ -553,6 +553,30 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
|||
return err.Error(), true
|
||||
}
|
||||
|
||||
gateway.SendPresence(
|
||||
c.xmpp,
|
||||
c.jid,
|
||||
gateway.SPFrom(strconv.FormatInt(chatID, 10)),
|
||||
gateway.SPType("unsubscribed"),
|
||||
)
|
||||
}
|
||||
// close secret chat
|
||||
case "close":
|
||||
chat, _, err := c.GetContactByID(chatID, nil)
|
||||
if err != nil {
|
||||
return err.Error(), true
|
||||
}
|
||||
|
||||
chatType := chat.Type.ChatTypeType()
|
||||
if chatType == client.TypeChatTypeSecret {
|
||||
chatTypeSecret, _ := chat.Type.(*client.ChatTypeSecret)
|
||||
_, err = c.client.CloseSecretChat(&client.CloseSecretChatRequest{
|
||||
SecretChatId: chatTypeSecret.SecretChatId,
|
||||
})
|
||||
if err != nil {
|
||||
return err.Error(), true
|
||||
}
|
||||
|
||||
gateway.SendPresence(
|
||||
c.xmpp,
|
||||
c.jid,
|
||||
|
|
Loading…
Reference in a new issue