markup

package
v0.0.0-...-f756a1e Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 1 Imported by: 0

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 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 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 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.

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