markup

package
v0.115.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 1 Imported by: 8

Documentation

Overview

Package markup contain bots inline markup builder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Button

func Button(text string) *tg.KeyboardButton

Button creates new plain text button.

func Buy

func Buy(text string) *tg.KeyboardButtonBuy

Buy creates button to buy a product.

func Callback

func Callback(text string, data []byte) *tg.KeyboardButtonCallback

Callback creates new callback button.

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) *tg.KeyboardButtonGame

Game creates button to start a game.

func Hide

func Hide() tg.ReplyMarkupClass

Hide creates markup to hide markup.

func InlineKeyboard

func InlineKeyboard(rows ...tg.KeyboardButtonRow) tg.ReplyMarkupClass

InlineKeyboard creates inline keyboard using given rows.

func InlineRow

func InlineRow(buttons ...tg.KeyboardButtonClass) tg.ReplyMarkupClass

InlineRow creates inline keyboard with single row using given buttons.

func InputURLAuth added in v0.85.0

func InputURLAuth(requestWriteAccess bool, text, fwdText, url string, bot tg.InputUserClass) *tg.InputKeyboardButtonURLAuth

InputURLAuth creates button to request a user to authorize via URL using Seamless Telegram Login. Can only be sent or received as part of an inline keyboard, use URLAuth for reply keyboards.

func InputUserProfile added in v0.85.0

func InputUserProfile(text string, user tg.InputUserClass) *tg.InputKeyboardButtonUserProfile

InputUserProfile creates button that links directly to a user profile. Can only be sent or received as part of an inline keyboard, use UserProfile for reply keyboards.

func Keyboard

func Keyboard(rows ...tg.KeyboardButtonRow) tg.ReplyMarkupClass

Keyboard creates keyboard using given rows.

func RequestGeoLocation

func RequestGeoLocation(text string) *tg.KeyboardButtonRequestGeoLocation

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) *tg.KeyboardButtonRequestPeer

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) *tg.KeyboardButtonRequestPhone

RequestPhone creates button to request a user's phone number.

func RequestPoll

func RequestPoll(text string, quiz bool) *tg.KeyboardButtonRequestPoll

RequestPoll creates button that allows the user to create and send a poll when pressed. Available only in private.

func Row

Row creates 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:

  1. users that are @mentioned in the text of the Message object;
  2. 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) *tg.KeyboardButtonSimpleWebView

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.KeyboardButtonClass) tg.ReplyMarkupClass

SingleRow creates keyboard with single row using given buttons.

func SwitchInline

func SwitchInline(text, query string, samePeer bool) *tg.KeyboardButtonSwitchInline

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) *tg.KeyboardButtonURL

URL creates new URL button.

func URLAuth

func URLAuth(text, url string, buttonID int, fwdText string) *tg.KeyboardButtonURLAuth

URLAuth creates button to request a user to authorize via URL using Seamless Telegram Login. Can only be sent or received as part of a reply keyboard, use InputURLAuth for inline keyboards.

func UserProfile added in v0.85.0

func UserProfile(text string, userID int64) *tg.KeyboardButtonUserProfile

UserProfile creates button that links directly to a user profile. Can only be sent or received as part of a reply keyboard, use InputUserProfile for inline keyboards.

func WebView added in v0.85.0

func WebView(text, url string) *tg.KeyboardButtonWebView

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

Build returns created keyboard.

func (*ReplyKeyboardMarkupBuilder) Resize

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

Selective sets flag to show the keyboard to specific users only. Targets:

  1. users that are @mentioned in the text of the Message object;
  2. 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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL