Support /join @publicgroup syntax
This commit is contained in:
parent
5698ce62c0
commit
ebc2f244d7
|
@ -61,7 +61,7 @@ var chatCommands = map[string]command{
|
||||||
"schedule": command{"{online | 2006-01-02T15:04:05 | 15:04:05} message", "schedules a message either to timestamp or to whenever the user goes online"},
|
"schedule": command{"{online | 2006-01-02T15:04:05 | 15:04:05} message", "schedules a message either to timestamp or to whenever the user goes online"},
|
||||||
"forward": command{"message_id target_chat", "forwards a message"},
|
"forward": command{"message_id target_chat", "forwards a message"},
|
||||||
"add": command{"@username", "add @username to your chat list"},
|
"add": command{"@username", "add @username to your chat list"},
|
||||||
"join": command{"https://t.me/invite_link", "join to chat via invite link"},
|
"join": command{"https://t.me/invite_link", "join to chat via invite link or @publicname"},
|
||||||
"group": command{"title", "create groupchat «title» with current user"},
|
"group": command{"title", "create groupchat «title» with current user"},
|
||||||
"supergroup": command{"title description", "create new supergroup «title» with «description»"},
|
"supergroup": command{"title description", "create new supergroup «title» with «description»"},
|
||||||
"channel": command{"title description", "create new channel «title» with «description»"},
|
"channel": command{"title description", "create new channel «title» with «description»"},
|
||||||
|
@ -623,17 +623,35 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.subscribeToID(chat.Id, chat)
|
c.subscribeToID(chat.Id, chat)
|
||||||
// join https://t.me/publichat
|
// join https://t.me/publichat or @publicchat
|
||||||
case "join":
|
case "join":
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return notEnoughArguments, true
|
return notEnoughArguments, true
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.client.JoinChatByInviteLink(&client.JoinChatByInviteLinkRequest{
|
if strings.HasPrefix(args[0], "@") {
|
||||||
InviteLink: args[0],
|
chat, err := c.client.SearchPublicChat(&client.SearchPublicChatRequest{
|
||||||
})
|
Username: args[0],
|
||||||
if err != nil {
|
})
|
||||||
return err.Error(), true
|
if err != nil {
|
||||||
|
return err.Error(), true
|
||||||
|
}
|
||||||
|
if chat == nil {
|
||||||
|
return "No error, but chat is nil", true
|
||||||
|
}
|
||||||
|
_, err = c.client.JoinChat(&client.JoinChatRequest{
|
||||||
|
ChatId: chat.Id,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err.Error(), true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_, err := c.client.JoinChatByInviteLink(&client.JoinChatByInviteLinkRequest{
|
||||||
|
InviteLink: args[0],
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err.Error(), true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// create new supergroup
|
// create new supergroup
|
||||||
case "supergroup":
|
case "supergroup":
|
||||||
|
|
Loading…
Reference in a new issue