tbtools

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileCbQryData

func CompileCbQryData(command, args string) string

Compiles callback data in command-args type. Concatenates command and args with \x00 symbol

func DecompileCbQryData

func DecompileCbQryData(cbQryData string) (command, args string)

Decompiles callback data in command-args type. Use to decompile output from CompileCbQryData.

func ParseMessageCommand

func ParseMessageCommand(msg *telegrambot.Message) (command string, args string)

Returns command name from msg. If command not found, return nothing. If command is not placed at the start of a message, returns nothing.

func StartChatAction

func StartChatAction(api telegrambot.API, params *telegrambot.SendChatActionParams) (stop func(), err error)

Starts continually send chat action every 4 seconds until stop function is called

Types

type ReplyKeyboardHandler

type ReplyKeyboardHandler [][]ReplyKeyboardHandlerButton

Stores keyboard with handlers for each buttons. See methods for this type for more information.

func (ReplyKeyboardHandler) HandleMessageKeyboardButton

func (rkh ReplyKeyboardHandler) HandleMessageKeyboardButton(msg *telegrambot.Message) (handled bool, err error)

Runs handler for a button stored in ReplyKeyboardHandler. If no handler found, returns handled == false

func (ReplyKeyboardHandler) ReplyMarkup

func (rkh ReplyKeyboardHandler) ReplyMarkup() telegrambot.ReplyMarkup

Returns reply markup with pre-defined options composed from ReplyKeyboardHandler

func (ReplyKeyboardHandler) ReplyMarkupWithOptions

func (rkh ReplyKeyboardHandler) ReplyMarkupWithOptions(options telegrambot.ReplyKeyboardMarkup) telegrambot.ReplyMarkup

Returns reply markup with passed options composed from ReplyKeyboardHandler. You should not pass keyboard field in options.

type ReplyKeyboardHandlerButton

type ReplyKeyboardHandlerButton struct {
	// Button text
	Text string
	// Used by HandleMessageKeyboardButton.
	// Must not be nil.
	Handler func() error
}

Button for ReplyKeyboardHandler