reply

package
v0.0.0-...-0bec941 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Reply Keyboard

reply_keyboard.png

Getting Started

package main

import (
	"context"

	"github.com/go-telegram/bot"
	"github.com/go-telegram/bot/models"
	"github.com/go-telegram/ui/keyboard/reply"
)

var demoReplyKeyboard *reply.ReplyKeyboard

func initReplyKeyboard(b *bot.Bot) {
	demoReplyKeyboard = reply.New(
		reply.WithPrefix("reply_keyboard"),
		reply.IsSelective(),
		reply.IsOneTimeKeyboard(),
	).
		Button("Button", b, bot.MatchTypeExact, onReplyKeyboardSelect).
		Row().
		Button("Cancel", b, bot.MatchTypeExact, onReplyKeyboardSelect)
}

func handlerReplyKeyboard(ctx context.Context, b *bot.Bot, update *models.Update) {
	b.SendMessage(ctx, &bot.SendMessageParams{
		ChatID:      update.Message.Chat.ID,
		Text:        "Select example command from reply keyboard:",
		ReplyMarkup: demoReplyKeyboard,
	})
}

func onReplyKeyboardSelect(ctx context.Context, b *bot.Bot, update *models.Update) {
	b.SendMessage(ctx, &bot.SendMessageParams{
		ChatID: update.Message.Chat.ID,
		Text:   "You selected: " + string(update.Message.Text),
	})
}

Options

See in options.go file

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(kb *ReplyKeyboard)

func InputFieldPlaceholder

func InputFieldPlaceholder(s string) Option

IsPersistent is a keyboard placeholder to be shown in the input field when the keyboard is active

func IsOneTimeKeyboard

func IsOneTimeKeyboard() Option

IsOneTimeKeyboard is a keyboard option that if setted will force the client to hide the keyboard after being used

func IsPersistent

func IsPersistent() Option

IsPersistent is a keyboard option that requests clients to always show the keyboard when the regular keyboard is hidden.

func IsSelective

func IsSelective() Option

IsSelective is a keyboard option that will show the keyboard only to specific users.

func ResizableKeyboard

func ResizableKeyboard() Option

ResizableKeyboard is a keyboard option that requests clients to resize the keyboard vertically for optimal fit.

func WithPrefix

func WithPrefix(s string) Option

WithPrefix is a keyboard option that sets a prefix for the widget

type ReplyKeyboard

type ReplyKeyboard struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *ReplyKeyboard

func (*ReplyKeyboard) Button

func (kb *ReplyKeyboard) Button(text string, b *bot.Bot, matchType bot.MatchType, handler bot.HandlerFunc) *ReplyKeyboard

func (*ReplyKeyboard) MarshalJSON

func (kb *ReplyKeyboard) MarshalJSON() ([]byte, error)

func (*ReplyKeyboard) Prefix

func (kb *ReplyKeyboard) Prefix() string

Prefix returns the prefix of the widget

func (*ReplyKeyboard) Row

func (kb *ReplyKeyboard) Row() *ReplyKeyboard

Jump to

Keyboard shortcuts

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