botkb

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 0 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button interface {
	GetText() string
	ButtonType() ButtonType
}

type ButtonStyle added in v0.2.6

type ButtonStyle string

ButtonStyle controls the color Telegram uses for an inline keyboard button.

An empty style preserves the client-specific Telegram appearance. The named styles require Telegram Bot API 9.4 or newer.

const (
	ButtonStyleDefault ButtonStyle = ""
	ButtonStylePrimary ButtonStyle = "primary"
	ButtonStyleSuccess ButtonStyle = "success"
	ButtonStyleDanger  ButtonStyle = "danger"

	// ButtonStylePositive is kept for source compatibility. Telegram calls
	// this style "success".
	ButtonStylePositive ButtonStyle = ButtonStyleSuccess

	// ButtonStyleDestructive is kept for source compatibility. Telegram calls
	// this style "danger".
	ButtonStyleDestructive ButtonStyle = ButtonStyleDanger
)

type ButtonType

type ButtonType int
const (
	ButtonTypeText ButtonType = iota
	ButtonTypeData
	ButtonTypeURL
	ButtonTypeSwitchInlineQuery
	ButtonTypeSwitchInlineQueryCurrentChat
	ButtonTypeCopyText
	ButtonTypeSwitchInlineQueryChosenChat
)

type CopyTextButton added in v0.2.6

type CopyTextButton struct {
	InlineButtonAppearance
	Text     string `json:"text"`
	CopyText string `json:"copy_text"`
}

CopyTextButton is an inline keyboard button that copies CopyText to the user's clipboard without sending a callback query to the bot.

func NewCopyTextButton added in v0.2.6

func NewCopyTextButton(text, copyText string) *CopyTextButton

func (CopyTextButton) ButtonType added in v0.2.6

func (CopyTextButton) ButtonType() ButtonType

func (CopyTextButton) GetText added in v0.2.6

func (b CopyTextButton) GetText() string

type DataButton

type DataButton struct {
	InlineButtonAppearance
	Text string `json:"text"`
	Data string `json:"data"`
}

func NewDataButton added in v0.2.1

func NewDataButton(text, data string) *DataButton

func (DataButton) ButtonType

func (DataButton) ButtonType() ButtonType

func (DataButton) GetText added in v0.2.0

func (b DataButton) GetText() string

type InlineButtonAppearance added in v0.2.6

type InlineButtonAppearance struct {
	Style             ButtonStyle `json:"style,omitempty"`
	IconCustomEmojiID string      `json:"icon_custom_emoji_id,omitempty"`
}

InlineButtonAppearance contains optional presentation metadata shared by Telegram keyboard buttons. Embed it in custom button types to let the Telegram renderer carry the same appearance metadata through. The historical name is retained because this metadata was first exposed for inline buttons.

func (InlineButtonAppearance) GetInlineButtonAppearance added in v0.2.6

func (a InlineButtonAppearance) GetInlineButtonAppearance() InlineButtonAppearance

GetInlineButtonAppearance allows platform renderers to read optional appearance metadata without coupling botkb to a Telegram API package.

type InlineButtonAppearanceProvider added in v0.2.6

type InlineButtonAppearanceProvider interface {
	GetInlineButtonAppearance() InlineButtonAppearance
}

type Keyboard

type Keyboard interface {
	// KeyboardType defines MessageKeyboard type
	KeyboardType() KeyboardType
}

Keyboard defines MessageKeyboard

type KeyboardType

type KeyboardType int

KeyboardType defines MessageKeyboard type

const (
	// KeyboardTypeNone for no MessageKeyboard
	// Used by: Telegram
	KeyboardTypeNone KeyboardType = iota

	// KeyboardTypeHide commands to hide MessageKeyboard
	// Used by: Telegram
	KeyboardTypeHide

	// KeyboardTypeInline for inline MessageKeyboard
	// Used by: Telegram
	KeyboardTypeInline

	// KeyboardTypeBottom for bottom MessageKeyboard
	// Used by: Telegram
	KeyboardTypeBottom

	// KeyboardTypeForceReply to force reply from a user
	// Used by: Telegram
	KeyboardTypeForceReply
)

type MessageKeyboard

type MessageKeyboard struct {
	Buttons [][]Button
	// contains filtered or unexported fields
}

func NewMessageKeyboard

func NewMessageKeyboard(kbType KeyboardType, buttons ...[]Button) *MessageKeyboard

func NewOnetimeKeyboard added in v0.2.3

func NewOnetimeKeyboard(buttons ...[]Button) *MessageKeyboard

func (MessageKeyboard) IsOneTime added in v0.2.3

func (k MessageKeyboard) IsOneTime() bool

func (MessageKeyboard) KeyboardType

func (k MessageKeyboard) KeyboardType() KeyboardType

type SwitchInlineQueryButton added in v0.2.0

type SwitchInlineQueryButton struct {
	InlineButtonAppearance
	Text  string `json:"text"`
	Query string `json:"query"`
}

func NewSwitchInlineQueryButton added in v0.2.1

func NewSwitchInlineQueryButton(text, query string) *SwitchInlineQueryButton

func (SwitchInlineQueryButton) ButtonType added in v0.2.0

func (SwitchInlineQueryButton) ButtonType() ButtonType

func (SwitchInlineQueryButton) GetText added in v0.2.0

func (b SwitchInlineQueryButton) GetText() string

type SwitchInlineQueryChosenChatButton added in v0.2.7

type SwitchInlineQueryChosenChatButton struct {
	InlineButtonAppearance
	Text              string `json:"text"`
	Query             string `json:"query"`
	AllowUserChats    bool   `json:"allow_user_chats,omitempty"`
	AllowBotChats     bool   `json:"allow_bot_chats,omitempty"`
	AllowGroupChats   bool   `json:"allow_group_chats,omitempty"`
	AllowChannelChats bool   `json:"allow_channel_chats,omitempty"`
}

SwitchInlineQueryChosenChatButton asks the user to choose a chat before opening the bot in inline mode there. The allow fields mirror Telegram's switch_inline_query_chosen_chat filters while keeping botkb independent of Telegram API types.

func NewSwitchInlineQueryChosenChatButton added in v0.2.7

func NewSwitchInlineQueryChosenChatButton(text, query string) *SwitchInlineQueryChosenChatButton

func (SwitchInlineQueryChosenChatButton) ButtonType added in v0.2.7

func (SwitchInlineQueryChosenChatButton) GetText added in v0.2.7

type SwitchInlineQueryCurrentChatButton added in v0.2.0

type SwitchInlineQueryCurrentChatButton struct {
	InlineButtonAppearance
	Text  string `json:"text"`
	Query string `json:"query"`
}

func NewSwitchInlineQueryCurrentChatButton added in v0.2.1

func NewSwitchInlineQueryCurrentChatButton(text, query string) *SwitchInlineQueryCurrentChatButton

func (SwitchInlineQueryCurrentChatButton) ButtonType added in v0.2.0

func (SwitchInlineQueryCurrentChatButton) GetText added in v0.2.0

type TextButton added in v0.2.2

type TextButton struct {
	InlineButtonAppearance
	Text string `json:"text"`
}

func NewTextButton added in v0.2.2

func NewTextButton(text string) *TextButton

func (TextButton) ButtonType added in v0.2.2

func (t TextButton) ButtonType() ButtonType

func (TextButton) GetText added in v0.2.2

func (t TextButton) GetText() string

type UrlButton

type UrlButton struct {
	InlineButtonAppearance
	Text string `json:"text"`
	URL  string `json:"url"`
}

func NewUrlButton added in v0.2.1

func NewUrlButton(text, url string) *UrlButton

func (UrlButton) ButtonType

func (UrlButton) ButtonType() ButtonType

func (UrlButton) GetText added in v0.2.0

func (b UrlButton) GetText() string

Jump to

Keyboard shortcuts

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