callback

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// CallbackQuery contains the raw received query
	*tgo.CallbackQuery

	// Bot is the bot instance which got the update.
	Bot *tgo.Bot

	// Storage contains an in-context storage used for middlewares to pass some data
	// to the next middleware or even the handler.
	Storage sync.Map
}

func (*Context) Answer

func (ctx *Context) Answer(options *tgo.AnswerCallbackQuery) error

Answer answers to the sent callback query. it fills the CallbackQueryId field by default.

func (*Context) Ask

func (ctx *Context) Ask(msg tgo.Sendable, timeout time.Duration) (question, answer *message.Context, err error)

Ask asks a question from the callback query sender and waits for the passed timeout for their response.

func (*Context) Send

func (ctx *Context) Send(msg tgo.Sendable) (*tgo.Message, error)

Send sends a message into the message's chat if exist, otherwise sends in the sender's chat, with the preferred ParseMode. It will set the target ChatId if not set.

func (*Context) Session

func (ctx *Context) Session() *sync.Map

Session returns the user's session storage. it will return the chat's session if user-id is zero.

type Handler

type Handler func(ctx *Context)

type Middleware

type Middleware func(ctx *Context) (ok bool)

type Route

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

type Router

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

func NewRouter

func NewRouter(middlewares ...Middleware) *Router

NewRouter returns a new message router

func (*Router) Handle

func (r *Router) Handle(filter tgo.Filter, handler Handler, middlewares ...Middleware)

Handle adds a new route to the Router

func (*Router) HandleUpdate

func (r *Router) HandleUpdate(bot *tgo.Bot, upd *tgo.Update) (used bool)

HandleUpdate implements tgo.Router interface

func (*Router) Setup

func (r *Router) Setup(bot *tgo.Bot) error

Setup implements tgo.Router interface

Jump to

Keyboard shortcuts

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