2023-01-19 23:08:59 +03:00
|
|
|
package nechotron
|
|
|
|
|
|
|
|
import "github.com/NicoNex/echotron/v3"
|
|
|
|
|
|
|
|
type InKeyboard struct {
|
|
|
|
Buttons [][]echotron.InlineKeyboardButton
|
|
|
|
}
|
|
|
|
|
2023-04-13 11:14:37 +03:00
|
|
|
func NewInlineKeyboard() *InKeyboard {
|
|
|
|
return &InKeyboard{}
|
|
|
|
}
|
|
|
|
|
2023-01-19 23:08:59 +03:00
|
|
|
func (i *InKeyboard) Row(buttons ...echotron.InlineKeyboardButton) *InKeyboard {
|
|
|
|
i.Buttons = append(i.Buttons, buttons)
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *InKeyboard) Markup() echotron.InlineKeyboardMarkup {
|
|
|
|
if len(i.Buttons) == 0 {
|
|
|
|
return echotron.InlineKeyboardMarkup{
|
|
|
|
InlineKeyboard: [][]echotron.InlineKeyboardButton{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return echotron.InlineKeyboardMarkup{
|
|
|
|
InlineKeyboard: i.Buttons,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func InButtonURL(text string, url string) echotron.InlineKeyboardButton {
|
|
|
|
return echotron.InlineKeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
URL: url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func InButtonCallback(text string, callback string) echotron.InlineKeyboardButton {
|
|
|
|
return echotron.InlineKeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
CallbackData: callback,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ReKeyboard struct {
|
|
|
|
Buttons [][]echotron.KeyboardButton
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *ReKeyboard) Row(buttons ...echotron.KeyboardButton) *ReKeyboard {
|
|
|
|
i.Buttons = append(i.Buttons, buttons)
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *ReKeyboard) Markup(oneTime bool) echotron.ReplyKeyboardMarkup {
|
|
|
|
if len(i.Buttons) == 0 {
|
|
|
|
return echotron.ReplyKeyboardMarkup{
|
|
|
|
OneTimeKeyboard: oneTime,
|
|
|
|
ResizeKeyboard: true,
|
|
|
|
Keyboard: [][]echotron.KeyboardButton{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return echotron.ReplyKeyboardMarkup{
|
|
|
|
OneTimeKeyboard: oneTime,
|
|
|
|
ResizeKeyboard: true,
|
|
|
|
Keyboard: i.Buttons,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReButton(text string) echotron.KeyboardButton {
|
|
|
|
return echotron.KeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Button struct {
|
|
|
|
text string
|
|
|
|
query string
|
|
|
|
url string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewButton() *Button {
|
|
|
|
return &Button{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Button) ReplyButton() echotron.KeyboardButton {
|
|
|
|
return echotron.KeyboardButton{Text: b.text}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Button) InlineCallback() echotron.InlineKeyboardButton {
|
|
|
|
return echotron.InlineKeyboardButton{CallbackData: b.query}
|
|
|
|
}
|
|
|
|
func (b *Button) InlineURL() echotron.InlineKeyboardButton {
|
|
|
|
return echotron.InlineKeyboardButton{URL: b.url}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Button) Text(text string) *Button {
|
|
|
|
b.text = text
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Button) Query(query string) *Button {
|
|
|
|
b.query = query
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Button) URL(url string) *Button {
|
|
|
|
b.url = url
|
|
|
|
return b
|
|
|
|
}
|