diff --git a/bot.go b/bot.go index e3a9a41f..9c94068c 100644 --- a/bot.go +++ b/bot.go @@ -1151,3 +1151,41 @@ func (b *Bot) Close() (bool, error) { return resp.Result, nil } + +// BotInfo represents a single object of MyName, BotDescription, BotShortDescription instances. +type BotInfo struct { + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + ShortDesc string `json:"short_description,omitempty"` +} + +// SetMyName change's the bot name. +func (b *Bot) SetMyName(name, language string) error { + params := map[string]string{ + "name": name, + "language_code": language, + } + + _, err := b.Raw("setMyName", params) + return err +} + +// MyName returns the current bot name for the given user language. +func (b *Bot) MyName(language string) (*BotInfo, error) { + params := map[string]string{ + "language_code": language, + } + + data, err := b.Raw("getMyName", params) + if err != nil { + return nil, err + } + + var resp struct { + Result *BotInfo + } + if err := json.Unmarshal(data, &resp); err != nil { + return nil, wrapError(err) + } + return resp.Result, nil +} diff --git a/chat.go b/chat.go index 74d6333b..19b93ffd 100644 --- a/chat.go +++ b/chat.go @@ -154,6 +154,9 @@ type ChatMemberUpdate struct { // (Optional) InviteLink which was used by the user to // join the chat; for joining by invite link events only. InviteLink *ChatInviteLink `json:"invite_link"` + + // (Optional) True, if the user joined the chat via a chat folder invite link. + ViaFolderLink bool `json:"via_chat_folder_invite_link"` } // Time returns the moment of the change in local time. diff --git a/inline.go b/inline.go index 2a889582..3442d34b 100644 --- a/inline.go +++ b/inline.go @@ -61,6 +61,46 @@ type QueryResponse struct { // (Optional) Parameter for the start message sent to the bot when user // presses the switch button. SwitchPMParameter string `json:"switch_pm_parameter,omitempty"` + + // (Optional) A JSON-serialized object describing a button to be shown + // above inline query results. + Button *QueryResponseButton `json:"button"` +} + +// QueryResponseButton represents a button to be shown above inline query results. +// You must use exactly one of the optional fields. +type QueryResponseButton struct { + // Label text on the button + Text string `json:"text"` + + // (Optional) Description of the Web App that will be launched when the + // user presses the button. The Web App will be able to switch back to the + // inline mode using the method switchInlineQuery inside the Web App. + WebApp *WebApp `json:"web_app"` + + // (Optional) Deep-linking parameter for the /start message sent to the bot + // when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. + Start string `json:"start_parameter"` +} + +// SwitchInlineQuery represents an inline button that switches the current +// user to inline mode in a chosen chat, with an optional default inline query. +type SwitchInlineQuery struct { + // (Optional) The default inline query to be inserted in the input field. + // If left empty, only the bot's username will be inserted. + Query string `json:"query"` + + // (Optional) True, if private chats with users can be chosen. + AllowUserChats bool `json:"allow_user_chats"` + + // (Optional) True, if private chats with bots can be chosen. + AllowBotChats bool `json:"allow_bot_chats"` + + // (Optional) True, if group and supergroup chats can be chosen. + AllowGroupChats bool `json:"allow_group_chats"` + + // (Optional) True, if channel chats can be chosen. + AllowChannelChats bool `json:"allow_channel_chats"` } // InlineResult represents a result of an inline query that was chosen diff --git a/markup.go b/markup.go index 29236db3..82d43e0f 100644 --- a/markup.go +++ b/markup.go @@ -271,13 +271,14 @@ type InlineButton struct { // It will be used as a callback endpoint. Unique string `json:"unique,omitempty"` - Text string `json:"text"` - URL string `json:"url,omitempty"` - Data string `json:"callback_data,omitempty"` - InlineQuery string `json:"switch_inline_query,omitempty"` - InlineQueryChat string `json:"switch_inline_query_current_chat"` - Login *Login `json:"login_url,omitempty"` - WebApp *WebApp `json:"web_app,omitempty"` + Text string `json:"text"` + URL string `json:"url,omitempty"` + Data string `json:"callback_data,omitempty"` + InlineQuery string `json:"switch_inline_query,omitempty"` + InlineQueryChat string `json:"switch_inline_query_current_chat"` + InlineQueryChosenChat *SwitchInlineQuery `json:"switch_inline_query_chosen_chat,omitempty"` + Login *Login `json:"login_url,omitempty"` + WebApp *WebApp `json:"web_app,omitempty"` } // MarshalJSON implements json.Marshaler interface.