Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c1bdc2fdf6
|
|||
|
83dca1ab39
|
|||
|
2cc2f96f02
|
25
keyboard.go
25
keyboard.go
@@ -7,10 +7,16 @@ import (
|
|||||||
"git.nix13.pw/scuroneko/extypes"
|
"git.nix13.pw/scuroneko/extypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ButtonStyleDanger KeyboardButtonStyle = "danger"
|
||||||
|
ButtonStyleSuccess KeyboardButtonStyle = "success"
|
||||||
|
ButtonStylePrimary KeyboardButtonStyle = "primary"
|
||||||
|
)
|
||||||
|
|
||||||
type InlineKbButtonBuilder struct {
|
type InlineKbButtonBuilder struct {
|
||||||
text string
|
text string
|
||||||
iconCustomEmojiID string
|
iconCustomEmojiID string
|
||||||
style InlineKeyboardButtonStyle
|
style KeyboardButtonStyle
|
||||||
url string
|
url string
|
||||||
callbackData string
|
callbackData string
|
||||||
}
|
}
|
||||||
@@ -22,7 +28,7 @@ func (b InlineKbButtonBuilder) SetIconCustomEmojiId(id string) InlineKbButtonBui
|
|||||||
b.iconCustomEmojiID = id
|
b.iconCustomEmojiID = id
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
func (b InlineKbButtonBuilder) SetStyle(style InlineKeyboardButtonStyle) InlineKbButtonBuilder {
|
func (b InlineKbButtonBuilder) SetStyle(style KeyboardButtonStyle) InlineKbButtonBuilder {
|
||||||
b.style = style
|
b.style = style
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
@@ -30,8 +36,8 @@ func (b InlineKbButtonBuilder) SetUrl(url string) InlineKbButtonBuilder {
|
|||||||
b.url = url
|
b.url = url
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
func (b InlineKbButtonBuilder) SetCallbackData(data *CallbackData) InlineKbButtonBuilder {
|
func (b InlineKbButtonBuilder) SetCallbackData(cmd string, args ...any) InlineKbButtonBuilder {
|
||||||
b.callbackData = data.ToJson()
|
b.callbackData = NewCallbackData(cmd, args...).ToJson()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,16 +72,23 @@ func (in *InlineKeyboard) append(button InlineKeyboardButton) *InlineKeyboard {
|
|||||||
in.CurrentLine = in.CurrentLine.Push(button)
|
in.CurrentLine = in.CurrentLine.Push(button)
|
||||||
return in
|
return in
|
||||||
}
|
}
|
||||||
|
|
||||||
func (in *InlineKeyboard) AddUrlButton(text, url string) *InlineKeyboard {
|
func (in *InlineKeyboard) AddUrlButton(text, url string) *InlineKeyboard {
|
||||||
return in.append(InlineKeyboardButton{Text: text, URL: url})
|
return in.append(InlineKeyboardButton{Text: text, URL: url})
|
||||||
}
|
}
|
||||||
|
func (in *InlineKeyboard) AddUrlButtonStyle(text string, style KeyboardButtonStyle, url string) *InlineKeyboard {
|
||||||
|
return in.append(InlineKeyboardButton{Text: text, Style: style, URL: url})
|
||||||
|
}
|
||||||
func (in *InlineKeyboard) AddCallbackButton(text string, cmd string, args ...any) *InlineKeyboard {
|
func (in *InlineKeyboard) AddCallbackButton(text string, cmd string, args ...any) *InlineKeyboard {
|
||||||
return in.append(InlineKeyboardButton{
|
return in.append(InlineKeyboardButton{
|
||||||
Text: text, CallbackData: NewCallbackData(cmd, args...).ToJson(),
|
Text: text, CallbackData: NewCallbackData(cmd, args...).ToJson(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func (in *InlineKeyboard) AddCustomButton(button InlineKeyboardButton) *InlineKeyboard {
|
func (in *InlineKeyboard) AddCallbackButtonStyle(text string, style KeyboardButtonStyle, cmd string, args ...any) *InlineKeyboard {
|
||||||
return in.append(button)
|
return in.append(InlineKeyboardButton{
|
||||||
|
Text: text, Style: style,
|
||||||
|
CallbackData: NewCallbackData(cmd, args...).ToJson(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
func (in *InlineKeyboard) AddButton(b InlineKbButtonBuilder) *InlineKeyboard {
|
func (in *InlineKeyboard) AddButton(b InlineKbButtonBuilder) *InlineKeyboard {
|
||||||
return in.append(b.build())
|
return in.append(b.build())
|
||||||
|
|||||||
4
types.go
4
types.go
@@ -128,12 +128,12 @@ type InlineKeyboardMarkup struct {
|
|||||||
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard,omitempty"`
|
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InlineKeyboardButtonStyle string
|
type KeyboardButtonStyle string
|
||||||
type InlineKeyboardButton struct {
|
type InlineKeyboardButton struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
CallbackData string `json:"callback_data,omitempty"`
|
CallbackData string `json:"callback_data,omitempty"`
|
||||||
Style InlineKeyboardButtonStyle `json:"style,omitempty"`
|
Style KeyboardButtonStyle `json:"style,omitempty"`
|
||||||
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package laniakea
|
package laniakea
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VersionString = "0.4.1"
|
VersionString = "0.4.3"
|
||||||
VersionMajor = 0
|
VersionMajor = 0
|
||||||
VersionMinor = 4
|
VersionMinor = 4
|
||||||
VersionPatch = 1
|
VersionPatch = 3
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user