Documentation
¶
Index ¶
- func Button(text, callbackData string) models.InlineKeyboardButton
- func CallbackButton(text string, payload interface{}) (models.InlineKeyboardButton, error)
- func CallbackGameButton(text string) models.InlineKeyboardButton
- func ContactButton(text string) models.KeyboardButton
- func CopyTextButton(text, copyText string) models.InlineKeyboardButton
- func LocationButton(text string) models.KeyboardButton
- func LoginButton(text, url string) models.InlineKeyboardButton
- func MustCallbackButton(text string, payload interface{}) models.InlineKeyboardButton
- func PackCallback(v interface{}) (string, error)
- func ParseCallback(raw string, out interface{}) bool
- func ParseMessageHTML(message *models.Message) string
- func ParseMessageMarkdown(message *models.Message) string
- func ParseTextHTML(text string, entities []models.MessageEntity) string
- func ParseTextMarkdown(text string, entities []models.MessageEntity) string
- func PayButton(text string) models.InlineKeyboardButton
- func PollButton(text, pollType string) models.KeyboardButton
- func RemoveKeyboard() *models.ReplyKeyboardRemove
- func RemoveKeyboardSelective() *models.ReplyKeyboardRemove
- func RequestChatButton(text string, requestID int, isChannel bool) models.KeyboardButton
- func RequestUsersButton(text string, requestID int) models.KeyboardButton
- func SwitchInlineButton(text, query string) models.InlineKeyboardButton
- func SwitchInlineChosenChatButton(text string, chosenChat *models.SwitchInlineQueryChosenChat) models.InlineKeyboardButton
- func SwitchInlineCurrentButton(text, query string) models.InlineKeyboardButton
- func TextButton(text string) models.KeyboardButton
- func URLButton(text, url string) models.InlineKeyboardButton
- func WebAppButton(text, url string) models.InlineKeyboardButton
- func WebAppReplyButton(text, url string) models.KeyboardButton
- type CallbackData
- type InlineKeyboardBuilder
- type ReplyKeyboardBuilder
- func (kb *ReplyKeyboardBuilder) Build() *models.ReplyKeyboardMarkup
- func (kb *ReplyKeyboardBuilder) OneTime(oneTime bool) *ReplyKeyboardBuilder
- func (kb *ReplyKeyboardBuilder) Persistent(persistent bool) *ReplyKeyboardBuilder
- func (kb *ReplyKeyboardBuilder) Placeholder(placeholder string) *ReplyKeyboardBuilder
- func (kb *ReplyKeyboardBuilder) Resize(resize bool) *ReplyKeyboardBuilder
- func (kb *ReplyKeyboardBuilder) Row(buttons ...models.KeyboardButton) *ReplyKeyboardBuilder
- func (kb *ReplyKeyboardBuilder) Selective(selective bool) *ReplyKeyboardBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Button ¶
func Button(text, callbackData string) models.InlineKeyboardButton
Button creates a simple text button with callback data
func CallbackButton ¶ added in v0.2.0
func CallbackButton(text string, payload interface{}) (models.InlineKeyboardButton, error)
CallbackButton builds an inline button and auto-packs callback payload.
func CallbackGameButton ¶ added in v0.2.2
func CallbackGameButton(text string) models.InlineKeyboardButton
CallbackGameButton creates a callback game button
func ContactButton ¶
func ContactButton(text string) models.KeyboardButton
ContactButton creates a button that requests contact
func CopyTextButton ¶ added in v0.2.2
func CopyTextButton(text, copyText string) models.InlineKeyboardButton
CopyTextButton creates a button that copies text to user's clipboard
func LocationButton ¶
func LocationButton(text string) models.KeyboardButton
LocationButton creates a button that requests location
func LoginButton ¶
func LoginButton(text, url string) models.InlineKeyboardButton
LoginButton creates a login URL button
func MustCallbackButton ¶ added in v0.2.0
func MustCallbackButton(text string, payload interface{}) models.InlineKeyboardButton
MustCallbackButton is like CallbackButton but panics on invalid payload. Useful for concise keyboard definitions.
func PackCallback ¶ added in v0.2.0
PackCallback packs a struct payload into Telegram callback data.
func ParseCallback ¶ added in v0.2.0
ParseCallback parses callback data string into provided struct pointer.
func ParseMessageHTML ¶
ParseMessageHTML extracts message text or caption as HTML.
func ParseMessageMarkdown ¶
ParseMessageMarkdown extracts message text or caption as MarkdownV2.
func ParseTextHTML ¶
func ParseTextHTML(text string, entities []models.MessageEntity) string
ParseTextHTML parses a text with entities to HTML.
func ParseTextMarkdown ¶
func ParseTextMarkdown(text string, entities []models.MessageEntity) string
ParseTextMarkdown parses a text with entities to MarkdownV2.
func PayButton ¶
func PayButton(text string) models.InlineKeyboardButton
PayButton creates a payment button
func PollButton ¶
func PollButton(text, pollType string) models.KeyboardButton
PollButton creates a button that requests a poll
func RemoveKeyboard ¶
func RemoveKeyboard() *models.ReplyKeyboardRemove
RemoveKeyboard creates a ReplyKeyboardRemove
func RemoveKeyboardSelective ¶
func RemoveKeyboardSelective() *models.ReplyKeyboardRemove
RemoveKeyboardSelective creates a selective ReplyKeyboardRemove
func RequestChatButton ¶
func RequestChatButton(text string, requestID int, isChannel bool) models.KeyboardButton
RequestChatButton creates a button that requests a chat
func RequestUsersButton ¶
func RequestUsersButton(text string, requestID int) models.KeyboardButton
RequestUsersButton creates a button that requests users
func SwitchInlineButton ¶
func SwitchInlineButton(text, query string) models.InlineKeyboardButton
SwitchInlineButton creates a button that switches to inline query
func SwitchInlineChosenChatButton ¶ added in v0.2.2
func SwitchInlineChosenChatButton(text string, chosenChat *models.SwitchInlineQueryChosenChat) models.InlineKeyboardButton
SwitchInlineChosenChatButton creates a button that switches to inline query in selected chats
func SwitchInlineCurrentButton ¶
func SwitchInlineCurrentButton(text, query string) models.InlineKeyboardButton
SwitchInlineCurrentButton creates a button that switches to inline query in current chat
func TextButton ¶
func TextButton(text string) models.KeyboardButton
TextButton creates a simple text button
func URLButton ¶
func URLButton(text, url string) models.InlineKeyboardButton
URLButton creates a button that opens a URL
func WebAppButton ¶
func WebAppButton(text, url string) models.InlineKeyboardButton
WebAppButton creates a button that opens a web app
func WebAppReplyButton ¶
func WebAppReplyButton(text, url string) models.KeyboardButton
WebAppReplyButton creates a button that opens a web app
Types ¶
type CallbackData ¶ added in v0.2.0
type CallbackData struct{}
CallbackData is a marker type for struct-based callback payloads.
Example:
type AdminCB struct {
tools.CallbackData `prefix:"admin"`
Section string
Action string
SubAction string
UserID int
}
If prefix tag is omitted, prefix is derived from struct name. Optional tag: separator:"|".
type InlineKeyboardBuilder ¶
type InlineKeyboardBuilder struct {
// contains filtered or unexported fields
}
InlineKeyboardBuilder helps build inline keyboards easily
func NewInlineKeyboard ¶
func NewInlineKeyboard() *InlineKeyboardBuilder
NewInlineKeyboard creates a new inline keyboard builder
func (*InlineKeyboardBuilder) Build ¶
func (kb *InlineKeyboardBuilder) Build() *models.InlineKeyboardMarkup
Build returns the final InlineKeyboardMarkup
func (*InlineKeyboardBuilder) Row ¶
func (kb *InlineKeyboardBuilder) Row(buttons ...models.InlineKeyboardButton) *InlineKeyboardBuilder
Row adds a new row to the keyboard
type ReplyKeyboardBuilder ¶
type ReplyKeyboardBuilder struct {
// contains filtered or unexported fields
}
ReplyKeyboardBuilder helps build reply keyboards easily
func NewReplyKeyboard ¶
func NewReplyKeyboard() *ReplyKeyboardBuilder
NewReplyKeyboard creates a new reply keyboard builder
func (*ReplyKeyboardBuilder) Build ¶
func (kb *ReplyKeyboardBuilder) Build() *models.ReplyKeyboardMarkup
Build returns the final ReplyKeyboardMarkup
func (*ReplyKeyboardBuilder) OneTime ¶
func (kb *ReplyKeyboardBuilder) OneTime(oneTime bool) *ReplyKeyboardBuilder
OneTime sets whether the keyboard should be one-time
func (*ReplyKeyboardBuilder) Persistent ¶
func (kb *ReplyKeyboardBuilder) Persistent(persistent bool) *ReplyKeyboardBuilder
Persistent sets whether the keyboard should be persistent
func (*ReplyKeyboardBuilder) Placeholder ¶
func (kb *ReplyKeyboardBuilder) Placeholder(placeholder string) *ReplyKeyboardBuilder
Placeholder sets the input field placeholder
func (*ReplyKeyboardBuilder) Resize ¶
func (kb *ReplyKeyboardBuilder) Resize(resize bool) *ReplyKeyboardBuilder
Resize sets whether the keyboard should be resized
func (*ReplyKeyboardBuilder) Row ¶
func (kb *ReplyKeyboardBuilder) Row(buttons ...models.KeyboardButton) *ReplyKeyboardBuilder
Row adds a new row to the keyboard
func (*ReplyKeyboardBuilder) Selective ¶
func (kb *ReplyKeyboardBuilder) Selective(selective bool) *ReplyKeyboardBuilder
Selective sets whether the keyboard should be selective