Documentation
¶
Overview ¶
Package markup contain bots inline markup builder.
Index ¶
- func Button(text string, style ...StyleOption) tg.KeyboardButton
- func Buy(text string, style ...StyleOption) tg.KeyboardInlineButton
- func Callback(text string, data []byte, style ...StyleOption) tg.KeyboardInlineButton
- func Copy(text, copyText string, style ...StyleOption) tg.KeyboardInlineButton
- func Disabled(text string, style ...StyleOption) tg.KeyboardInlineButton
- func ForceReply(singleUse, selective bool) tg.ReplyMarkupClass
- func Game(text string, style ...StyleOption) tg.KeyboardInlineButton
- func Hide() tg.ReplyMarkupClass
- func InlineButtonRow(buttons ...tg.KeyboardInlineButton) tg.KeyboardInlineButtonRow
- func InlineKeyboard(rows ...tg.KeyboardInlineButtonRow) tg.ReplyMarkupClass
- func InlineRow(buttons ...tg.KeyboardInlineButton) tg.ReplyMarkupClass
- func InputRequestPeer(text string, typ tg.InputButtonTypeRequestPeer, style ...StyleOption) tg.KeyboardButton
- func InputURLAuth(requestWriteAccess bool, text, fwdText, url string, bot tg.InputUserClass, ...) tg.KeyboardInlineButton
- func InputUserProfile(text string, user tg.InputUserClass, style ...StyleOption) tg.KeyboardInlineButton
- func Keyboard(rows ...tg.KeyboardButtonRow) tg.ReplyMarkupClass
- func RequestGeoLocation(text string, style ...StyleOption) tg.KeyboardButton
- func RequestPeer(text string, buttonID int, peerType tg.RequestPeerTypeClass, ...) tg.KeyboardButton
- func RequestPhone(text string, style ...StyleOption) tg.KeyboardButton
- func RequestPoll(text string, quiz bool, style ...StyleOption) tg.KeyboardButton
- func Row(buttons ...tg.KeyboardButton) tg.KeyboardButtonRow
- func SelectiveHide() tg.ReplyMarkupClass
- func SimpleWebView(text, url string, style ...StyleOption) tg.KeyboardButton
- func SingleRow(buttons ...tg.KeyboardButton) tg.ReplyMarkupClass
- func SwitchInline(text, query string, samePeer bool, style ...StyleOption) tg.KeyboardInlineButton
- func URL(text, url string, style ...StyleOption) tg.KeyboardInlineButton
- func URLAuth(text, url string, buttonID int, fwdText string, style ...StyleOption) tg.KeyboardInlineButton
- func UserProfile(text string, userID int64, style ...StyleOption) tg.KeyboardInlineButton
- func WebView(text, url string, style ...StyleOption) tg.KeyboardInlineButton
- type ReplyKeyboardMarkupBuilder
- func (b *ReplyKeyboardMarkupBuilder) Build(rows ...tg.KeyboardButtonRow) tg.ReplyMarkupClass
- func (b *ReplyKeyboardMarkupBuilder) ForceReply() *ReplyKeyboardMarkupBuilder
- func (b *ReplyKeyboardMarkupBuilder) Persistent() *ReplyKeyboardMarkupBuilder
- func (b *ReplyKeyboardMarkupBuilder) Placeholder(placeholder string) *ReplyKeyboardMarkupBuilder
- func (b *ReplyKeyboardMarkupBuilder) Resize() *ReplyKeyboardMarkupBuilder
- func (b *ReplyKeyboardMarkupBuilder) Selective() *ReplyKeyboardMarkupBuilder
- func (b *ReplyKeyboardMarkupBuilder) SingleUse() *ReplyKeyboardMarkupBuilder
- type StyleOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Button ¶
func Button(text string, style ...StyleOption) tg.KeyboardButton
Button creates new plain text button.
func Buy ¶
func Buy(text string, style ...StyleOption) tg.KeyboardInlineButton
Buy creates button to buy a product.
func Callback ¶
func Callback(text string, data []byte, style ...StyleOption) tg.KeyboardInlineButton
Callback creates new callback button.
func Copy ¶
func Copy(text, copyText string, style ...StyleOption) tg.KeyboardInlineButton
Copy creates button that copies copyText to the clipboard when pressed.
func Disabled ¶
func Disabled(text string, style ...StyleOption) tg.KeyboardInlineButton
Disabled creates button that does nothing when pressed.
func ForceReply ¶
func ForceReply(singleUse, selective bool) tg.ReplyMarkupClass
ForceReply creates markup to force the user to send a reply.
func Game ¶
func Game(text string, style ...StyleOption) tg.KeyboardInlineButton
Game creates button to start a game.
func InlineButtonRow ¶
func InlineButtonRow(buttons ...tg.KeyboardInlineButton) tg.KeyboardInlineButtonRow
InlineButtonRow creates inline keyboard row.
func InlineKeyboard ¶
func InlineKeyboard(rows ...tg.KeyboardInlineButtonRow) tg.ReplyMarkupClass
InlineKeyboard creates inline keyboard using given rows.
func InlineRow ¶
func InlineRow(buttons ...tg.KeyboardInlineButton) tg.ReplyMarkupClass
InlineRow creates inline keyboard with single row using given buttons.
func InputRequestPeer ¶
func InputRequestPeer(text string, typ tg.InputButtonTypeRequestPeer, style ...StyleOption) tg.KeyboardButton
InputRequestPeer creates button that prompts the user to select and share a peer with the bot, requesting the peer's name, username and/or photo. Use it to send a button, use RequestPeer to handle a received one.
func InputURLAuth ¶ added in v0.85.0
func InputURLAuth( requestWriteAccess bool, text, fwdText, url string, bot tg.InputUserClass, style ...StyleOption, ) tg.KeyboardInlineButton
InputURLAuth creates button to request a user to authorize via URL using Seamless Telegram Login. Use it to send a button, use URLAuth to handle a received one.
func InputUserProfile ¶ added in v0.85.0
func InputUserProfile(text string, user tg.InputUserClass, style ...StyleOption) tg.KeyboardInlineButton
InputUserProfile creates button that links directly to a user profile. Use it to send a button, use UserProfile to handle a received one.
func Keyboard ¶
func Keyboard(rows ...tg.KeyboardButtonRow) tg.ReplyMarkupClass
Keyboard creates keyboard using given rows.
func RequestGeoLocation ¶
func RequestGeoLocation(text string, style ...StyleOption) tg.KeyboardButton
RequestGeoLocation creates button to request a user's geo location.
func RequestPeer ¶ added in v0.85.0
func RequestPeer(text string, buttonID int, peerType tg.RequestPeerTypeClass, style ...StyleOption) tg.KeyboardButton
RequestPeer creates button that prompts the user to select and share a peer with the bot using messages.sendBotRequestedPeer.
func RequestPhone ¶
func RequestPhone(text string, style ...StyleOption) tg.KeyboardButton
RequestPhone creates button to request a user's phone number.
func RequestPoll ¶
func RequestPoll(text string, quiz bool, style ...StyleOption) tg.KeyboardButton
RequestPoll creates button that allows the user to create and send a poll when pressed. Available only in private.
func Row ¶
func Row(buttons ...tg.KeyboardButton) tg.KeyboardButtonRow
Row creates reply keyboard row.
func SelectiveHide ¶
func SelectiveHide() tg.ReplyMarkupClass
SelectiveHide creates markup to hide markup. Use this builder if you want to remove the keyboard for specific users only. Targets:
- users that are @mentioned in the text of the Message object;
- if the bot's message is a reply (has reply_to_message_id), sender of the original message.
Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
func SimpleWebView ¶ added in v0.85.0
func SimpleWebView(text, url string, style ...StyleOption) tg.KeyboardButton
SimpleWebView creates button to open a bot web app using messages.requestSimpleWebView, without sending user information to the web app. Can only be sent or received as part of a reply keyboard, use WebView for inline keyboards.
func SingleRow ¶
func SingleRow(buttons ...tg.KeyboardButton) tg.ReplyMarkupClass
SingleRow creates keyboard with single row using given buttons.
func SwitchInline ¶
func SwitchInline(text, query string, samePeer bool, style ...StyleOption) tg.KeyboardInlineButton
SwitchInline creates button to force a user to switch to inline mode. Pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field.
If samePeer set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field.
func URL ¶
func URL(text, url string, style ...StyleOption) tg.KeyboardInlineButton
URL creates new URL button.
func URLAuth ¶
func URLAuth(text, url string, buttonID int, fwdText string, style ...StyleOption) tg.KeyboardInlineButton
URLAuth creates button to request a user to authorize via URL using Seamless Telegram Login. Use InputURLAuth to send such a button.
func UserProfile ¶ added in v0.85.0
func UserProfile(text string, userID int64, style ...StyleOption) tg.KeyboardInlineButton
UserProfile creates button that links directly to a user profile. Use InputUserProfile to send such a button.
func WebView ¶ added in v0.85.0
func WebView(text, url string, style ...StyleOption) tg.KeyboardInlineButton
WebView creates button to open a bot web app using messages.requestWebView, sending over user information after user confirmation. Can only be sent or received as part of an inline keyboard, use SimpleWebView for reply keyboards.
Types ¶
type ReplyKeyboardMarkupBuilder ¶
type ReplyKeyboardMarkupBuilder struct {
// contains filtered or unexported fields
}
ReplyKeyboardMarkupBuilder is a keyboard markup builder.
func BuildKeyboard ¶
func BuildKeyboard() *ReplyKeyboardMarkupBuilder
BuildKeyboard creates keyboard builder.
func (*ReplyKeyboardMarkupBuilder) Build ¶
func (b *ReplyKeyboardMarkupBuilder) Build(rows ...tg.KeyboardButtonRow, ) tg.ReplyMarkupClass
Build returns created keyboard.
func (*ReplyKeyboardMarkupBuilder) ForceReply ¶
func (b *ReplyKeyboardMarkupBuilder) ForceReply() *ReplyKeyboardMarkupBuilder
ForceReply sets flag to force the user to send a reply.
func (*ReplyKeyboardMarkupBuilder) Persistent ¶
func (b *ReplyKeyboardMarkupBuilder) Persistent() *ReplyKeyboardMarkupBuilder
Persistent sets flag to request clients to always show the keyboard when the regular keyboard is hidden.
func (*ReplyKeyboardMarkupBuilder) Placeholder ¶
func (b *ReplyKeyboardMarkupBuilder) Placeholder(placeholder string) *ReplyKeyboardMarkupBuilder
Placeholder sets the placeholder to be shown in the input field when the keyboard is active.
func (*ReplyKeyboardMarkupBuilder) Resize ¶
func (b *ReplyKeyboardMarkupBuilder) Resize() *ReplyKeyboardMarkupBuilder
Resize sets flag to request clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). If not set, the custom keyboard is always of the same height as the app's standard keyboard.
func (*ReplyKeyboardMarkupBuilder) Selective ¶
func (b *ReplyKeyboardMarkupBuilder) Selective() *ReplyKeyboardMarkupBuilder
Selective sets flag to show the keyboard to specific users only. Targets:
- users that are @mentioned in the text of the Message object;
- if the bot's message is a reply (has reply_to_message_id), sender of the original message.
Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.
func (*ReplyKeyboardMarkupBuilder) SingleUse ¶
func (b *ReplyKeyboardMarkupBuilder) SingleUse() *ReplyKeyboardMarkupBuilder
SingleUse sets flag to request clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again.
type StyleOption ¶ added in v0.160.0
type StyleOption func(s *tg.KeyboardButtonStyle)
StyleOption is a functional parameter that configures the tg.KeyboardButtonStyle of a button, allowing a custom background color and a custom emoji label.
See https://core.telegram.org/api/bots/buttons#button-styles.
func StyleBgDanger ¶ added in v0.160.0
func StyleBgDanger() StyleOption
StyleBgDanger sets a red background color, recommended for destructive actions.
func StyleBgPrimary ¶ added in v0.160.0
func StyleBgPrimary() StyleOption
StyleBgPrimary sets a dark blue background color, recommended for main actions.
func StyleBgSuccess ¶ added in v0.160.0
func StyleBgSuccess() StyleOption
StyleBgSuccess sets a green background color, recommended for positive actions.
func StyleIcon ¶ added in v0.160.0
func StyleIcon(icon int64) StyleOption
StyleIcon sets the ID of a custom emoji to be displayed before the button's label.