Merge pull request #292 from godande/develop

Introduced keyboard constructors
pull/300/head
Ian P Badtrousers 4 years ago committed by GitHub
commit 1a558989dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1398,3 +1398,7 @@ func (b *Bot) SetCommands(cmds []Command) error {
_, err := b.Raw("setMyCommands", params)
return err
}
func (b *Bot) NewMarkup() *ReplyMarkup {
return &ReplyMarkup{}
}

@ -161,6 +161,7 @@ func (pt PollType) MarshalJSON() ([]byte, error) {
}
type row []Btn
func (r *ReplyMarkup) Row(many ...Btn) row {
return many
}
@ -202,6 +203,37 @@ func (r *ReplyMarkup) Reply(rows ...row) {
r.ReplyKeyboard = replyKeys
}
func (r *ReplyMarkup) Text(unique, text string) Btn {
return Btn{Unique: unique, Text: text}
}
func (r *ReplyMarkup) URL(unique, text, url string) Btn {
return Btn{Unique: unique, Text: text, URL: url}
}
func (r *ReplyMarkup) Query(unique string, text, query string) Btn {
return Btn{Unique: unique, Text: text, InlineQuery: query}
}
func (r *ReplyMarkup) QueryChat(unique string, text, query string) Btn {
return Btn{Unique: unique, Text: text, InlineQueryChat: query}
}
func (r *ReplyMarkup) Login(unique, text string, login *Login) Btn {
return Btn{Unique: unique, Login: login, 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(poll PollType) Btn {
return Btn{Poll: poll}
}
// Btn is a constructor button, which will later become either a reply, or an inline button.
type Btn struct {

Loading…
Cancel
Save