message

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// Message contains the raw received message
	*tgo.Message

	// 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) Ask

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

Ask asks a question from the message's sender and waits for the passed timeout for their response.

func (*Context) Delete

func (ctx *Context) Delete() error

Delete deletes the received message.

func (*Context) Reply

func (ctx *Context) Reply(msg tgo.Replyable) (*tgo.Message, error)

Reply replies to the current message with the preferred ParseMode. It will pass/override the ChatId and ReplyToMessageId field.

func (*Context) Send

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

Send sends a message into the current 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.

ToDo: make sure that we are getting the chat id in the right way.

func (*Context) String

func (m *Context) String() string

String returns the message's text or media caption

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