tools

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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

func PackCallback(v interface{}) (string, error)

PackCallback packs a struct payload into Telegram callback data.

func ParseCallback added in v0.2.0

func ParseCallback(raw string, out interface{}) bool

ParseCallback parses callback data string into provided struct pointer.

func ParseMessageHTML

func ParseMessageHTML(message *models.Message) string

ParseMessageHTML extracts message text or caption as HTML.

func ParseMessageMarkdown

func ParseMessageMarkdown(message *models.Message) string

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

Build returns the final InlineKeyboardMarkup

func (*InlineKeyboardBuilder) Row

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

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

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

Jump to

Keyboard shortcuts

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