diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-07 20:56:53 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-07 20:56:53 +0300 |
commit | ea0d0df226aecf2e17bf3f137899e053155df1c4 (patch) | |
tree | a627b48d35e0f74182740184f4c0f998e6df9dba | |
parent | 589876eef53ad2a64ffec9e1e47579b80465ac68 (diff) |
Add /add command
-rw-r--r-- | telegram/commands.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index 3682535..91bc9d5 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -334,6 +334,28 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) text := regex.ReplaceAllString(messageText.Text.Text, strings.Join(args[1:], " ")) c.ProcessOutgoingMessage(chatID, text, message.Id, "") + // add @contact + case "add": + if len(args) < 1 { + return notEnoughArguments, true + } + + chat, err := c.client.SearchPublicChat(&client.SearchPublicChatRequest{ + Username: args[0], + }) + if err != nil { + return err.Error(), true + } + if chat == nil { + return "No error, but chat is nil", true + } + + gateway.SendPresence( + c.xmpp, + c.jid, + gateway.SPFrom(strconv.FormatInt(chat.Id, 10)), + gateway.SPType("subscribe"), + ) case "help": return helpString(helpTypeChat), true default: |