From 49a392391a437f2fda85f24d7f12eec7203aa31f Mon Sep 17 00:00:00 2001 From: dande Date: Wed, 13 May 2020 18:21:07 +0300 Subject: [PATCH 1/3] keyboards: added constructors --- bot.go | 4 ++++ options.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/bot.go b/bot.go index 235db6a..a7d8e7a 100644 --- a/bot.go +++ b/bot.go @@ -1365,3 +1365,7 @@ func (b *Bot) SetCommands(cmds []Command) error { _, err := b.Raw("setMyCommands", params) return err } + +func(b *Bot) NewMarkup() *ReplyMarkup{ + return &ReplyMarkup{} +} \ No newline at end of file diff --git a/options.go b/options.go index 5d5b498..091a9e1 100644 --- a/options.go +++ b/options.go @@ -202,6 +202,38 @@ 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,url string) Btn { + return Btn{Unique: unique, URL: url} +} + + +func(r *ReplyMarkup) Query(unique string, query string) Btn { + return Btn{Unique: unique, InlineQuery: query} +} + +func(r *ReplyMarkup) QueryChat(unique string, query string) Btn { + return Btn{Unique: unique, 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 { From ef05beb4e7fe15799031d0c3a129cd5e21296500 Mon Sep 17 00:00:00 2001 From: dande Date: Wed, 13 May 2020 18:29:49 +0300 Subject: [PATCH 2/3] keyboards: fixed url and query constructors --- options.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/options.go b/options.go index 091a9e1..ba42398 100644 --- a/options.go +++ b/options.go @@ -206,17 +206,17 @@ func(r *ReplyMarkup) Text(unique,text string) Btn { return Btn{Unique: unique, Text: text} } -func(r *ReplyMarkup) URL(unique,url string) Btn { - return Btn{Unique: unique, URL: url} +func(r *ReplyMarkup) URL(unique,text,url string) Btn { + return Btn{Unique: unique, Text: text, URL: url} } -func(r *ReplyMarkup) Query(unique string, query string) Btn { - return Btn{Unique: unique, InlineQuery: query} +func(r *ReplyMarkup) Query(unique string, text,query string) Btn { + return Btn{Unique: unique,Text: text, InlineQuery: query} } -func(r *ReplyMarkup) QueryChat(unique string, query string) Btn { - return Btn{Unique: unique, InlineQueryChat: 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 { From ef00a90aefecf9ca0cc18ac6da86994f4aaa6702 Mon Sep 17 00:00:00 2001 From: dande Date: Wed, 13 May 2020 19:55:06 +0300 Subject: [PATCH 3/3] options: go fmt --- bot.go | 4 ++-- callbacks.go | 2 +- options.go | 26 +++++++++++++------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bot.go b/bot.go index a7d8e7a..2d81ada 100644 --- a/bot.go +++ b/bot.go @@ -1366,6 +1366,6 @@ func (b *Bot) SetCommands(cmds []Command) error { return err } -func(b *Bot) NewMarkup() *ReplyMarkup{ +func (b *Bot) NewMarkup() *ReplyMarkup { return &ReplyMarkup{} -} \ No newline at end of file +} diff --git a/callbacks.go b/callbacks.go index fcf3c75..527d4b8 100644 --- a/callbacks.go +++ b/callbacks.go @@ -91,7 +91,7 @@ func (t *InlineButton) With(data string) *InlineButton { InlineQueryChat: t.InlineQueryChat, Login: t.Login, - Data: data, + Data: data, } } diff --git a/options.go b/options.go index ba42398..7641e5e 100644 --- a/options.go +++ b/options.go @@ -161,6 +161,7 @@ func (pt PollType) MarshalJSON() ([]byte, error) { } type row []Btn + func (r *ReplyMarkup) Row(many ...Btn) row { return many } @@ -202,36 +203,35 @@ func (r *ReplyMarkup) Reply(rows ...row) { r.ReplyKeyboard = replyKeys } -func(r *ReplyMarkup) Text(unique,text string) Btn { +func (r *ReplyMarkup) Text(unique, text string) Btn { return Btn{Unique: unique, Text: text} } -func(r *ReplyMarkup) URL(unique,text,url string) Btn { +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) 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) 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 { +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) 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) Location(text string) Btn { + return Btn{Location: true, Text: text} } -func(r *ReplyMarkup) Poll(poll PollType) Btn { +func (r *ReplyMarkup) Poll(poll PollType) Btn { return Btn{Poll: poll} }