Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: implement 6.7 features #654

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 40 additions & 0 deletions inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions markup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading