Skip to content

Commit

Permalink
markup: add reply user and chat Btn constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Nov 20, 2023
1 parent 10d3480 commit b1cf07b
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions markup.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ func (r *ReplyMarkup) copy() *ReplyMarkup {

// Btn is a constructor button, which will later become either a reply, or an inline button.
type Btn struct {
Unique string `json:"unique,omitempty"`
Text string `json:"text,omitempty"`
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,omitempty"`
Contact bool `json:"request_contact,omitempty"`
Location bool `json:"request_location,omitempty"`
Poll PollType `json:"request_poll,omitempty"`
Login *Login `json:"login_url,omitempty"`
WebApp *WebApp `json:"web_app,omitempty"`
Unique string `json:"unique,omitempty"`
Text string `json:"text,omitempty"`
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,omitempty"`
Login *Login `json:"login_url,omitempty"`
WebApp *WebApp `json:"web_app,omitempty"`
Contact bool `json:"request_contact,omitempty"`
Location bool `json:"request_location,omitempty"`
Poll PollType `json:"request_poll,omitempty"`
User *ReplyRecipient `json:"request_user,omitempty"`
Chat *ReplyRecipient `json:"request_chat,omitempty"`
}

// Row represents an array of buttons, a row.
Expand Down Expand Up @@ -160,18 +162,6 @@ func (r *ReplyMarkup) Text(text string) Btn {
return Btn{Text: text}
}

func (r *ReplyMarkup) Contact(text string) Btn {
return Btn{Contact: true, Text: text}
}

func (r *ReplyMarkup) Location(text string) Btn {
return Btn{Location: true, Text: text}
}

func (r *ReplyMarkup) Poll(text string, poll PollType) Btn {
return Btn{Poll: poll, Text: text}
}

func (r *ReplyMarkup) Data(text, unique string, data ...string) Btn {
return Btn{
Unique: unique,
Expand All @@ -192,6 +182,26 @@ func (r *ReplyMarkup) QueryChat(text, query string) Btn {
return Btn{Text: text, InlineQueryChat: query}
}

func (r *ReplyMarkup) Contact(text string) Btn {
return Btn{Contact: true, Text: text}
}

func (r *ReplyMarkup) Location(text string) Btn {
return Btn{Location: true, Text: text}
}

func (r *ReplyMarkup) Poll(text string, poll PollType) Btn {
return Btn{Poll: poll, Text: text}
}

func (r *ReplyMarkup) User(text string, user *ReplyRecipient) Btn {
return Btn{Text: text, User: user}
}

func (r *ReplyMarkup) Chat(text string, chat *ReplyRecipient) Btn {
return Btn{Text: text, Chat: chat}
}

func (r *ReplyMarkup) Login(text string, login *Login) Btn {
return Btn{Login: login, Text: text}
}
Expand Down Expand Up @@ -310,6 +320,8 @@ func (b Btn) Reply() *ReplyButton {
Contact: b.Contact,
Location: b.Location,
Poll: b.Poll,
User: b.User,
Chat: b.Chat,
WebApp: b.WebApp,
}
}
Expand Down

0 comments on commit b1cf07b

Please sign in to comment.