diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-08 02:36:29 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-08 02:36:29 +0300 |
commit | 5da39f4aa9201d02bbcecb4dd0319b102846d1fe (patch) | |
tree | 53aa9c08cea3c6509e013837a5c39f10e06cc272 | |
parent | 58aefc5232093a75a7265c107a9e29628ff9f140 (diff) |
Add /secret and /group commands
-rw-r--r-- | telegram/commands.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index f71040d..74406f5 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -395,6 +395,34 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) if err != nil { return err.Error(), true } + // create new secret chat with current user + case "secret": + _, user, err := c.GetContactByID(chatID, nil) + if err != nil || user == nil { + return "User not found", true + } + + _, err = c.client.CreateNewSecretChat(&client.CreateNewSecretChatRequest{ + UserId: int32(chatID), + }) + if err != nil { + return err.Error(), true + } + // create group chat with current user + case "group": + if len(args) < 1 { + return notEnoughArguments, true + } + + if chatID > 0 { + _, err := c.client.CreateNewBasicGroupChat(&client.CreateNewBasicGroupChatRequest{ + UserIds: []int32{int32(chatID)}, + Title: args[0], + }) + if err != nil { + return err.Error(), true + } + } case "help": return helpString(helpTypeChat), true default: |