Documentation ¶
Overview ¶
Package telegohandler provides handlers & predicates for Telego.
Bot handlers provide an easy way to make net/http like handlers, but with predicates instead of paths. In addition to just predicates it, also provides groups and middlewares.
You can create BotHandler, register new handlers and start processing updates from the update channel which you provide. All handlers process updates concurrently, but keep in mind that predicates are checked sequentially. This gives an ability to process one update only with the first matched handler.
Example ¶
This example shows how you can create BotHandler and register new handlers. Note, that order of registration directly impacts order of checking matched handlers, and only the first matched handler will process the update.
package main import ( "fmt" "os" "github.com/mymmrac/telego" th "github.com/mymmrac/telego/telegohandler" tu "github.com/mymmrac/telego/telegoutil" ) func main() { botToken := os.Getenv("TOKEN") // Note: Please keep in mind that default logger may expose sensitive information, use in development only bot, err := telego.NewBot(botToken, telego.WithDefaultDebugLogger()) if err != nil { fmt.Println(err) os.Exit(1) } // Get updates channel updates, _ := bot.UpdatesViaLongPolling(nil) // Create bot handler and specify from where to get updates bh, _ := th.NewBotHandler(bot, updates) // Stop handling updates defer bh.Stop() // Stop getting updates defer bot.StopLongPolling() // Register new handler with match on command `/start` bh.Handle(func(bot *telego.Bot, update telego.Update) { // Send message _, _ = bot.SendMessage(tu.Messagef( tu.ID(update.Message.Chat.ID), "Hello %s!", update.Message.From.FirstName, )) }, th.CommandEqual("start")) // Register new handler with match on any command // Handlers will match only once and in order of registration, so this handler will be called on any command // except `/start` command bh.Handle(func(bot *telego.Bot, update telego.Update) { // Send message _, _ = bot.SendMessage(tu.Message( tu.ID(update.Message.Chat.ID), "Unknown command, use /start", )) }, th.AnyCommand()) // Start handling updates bh.Start() }
One more example of handler usage. It shows how to use specific handlers to process individual fields of telego.Update.
package main import ( "fmt" "os" "github.com/mymmrac/telego" th "github.com/mymmrac/telego/telegohandler" tu "github.com/mymmrac/telego/telegoutil" ) func main() { botToken := os.Getenv("TOKEN") // Note: Please keep in mind that default logger may expose sensitive information, use in development only bot, err := telego.NewBot(botToken, telego.WithDefaultDebugLogger()) if err != nil { fmt.Println(err) os.Exit(1) } // Get updates channel updates, _ := bot.UpdatesViaLongPolling(nil) // Create bot handler and specify from where to get updates bh, _ := th.NewBotHandler(bot, updates) // Stop handling updates defer bh.Stop() // Stop getting updates defer bot.StopLongPolling() // Register new handler with match on command `/start` bh.HandleMessage(func(bot *telego.Bot, message telego.Message) { // Send a message with inline keyboard _, _ = bot.SendMessage(tu.Messagef( tu.ID(message.Chat.ID), "Hello %s!", message.From.FirstName, ).WithReplyMarkup(tu.InlineKeyboard( tu.InlineKeyboardRow(tu.InlineKeyboardButton("Go!").WithCallbackData("go"))), )) }, th.CommandEqual("start")) // Register new handler with match on a call back query with data equal to `go` and non-nil message bh.HandleCallbackQuery(func(bot *telego.Bot, query telego.CallbackQuery) { // Send message _, _ = bot.SendMessage(tu.Message(tu.ID(query.Message.Chat.ID), "GO GO GO")) // Answer callback query _ = bot.AnswerCallbackQuery(tu.CallbackQuery(query.ID).WithText("Done")) }, th.AnyCallbackQueryWithMessage(), th.CallbackDataEqual("go")) // Start handling updates bh.Start() }
In this example, usage of groups and middleware will be shown.
package main import ( "fmt" "os" "github.com/mymmrac/telego" th "github.com/mymmrac/telego/telegohandler" ) func main() { botToken := os.Getenv("TOKEN") // Note: Please keep in mind that default logger may expose sensitive information, use in development only bot, err := telego.NewBot(botToken, telego.WithDefaultDebugLogger()) if err != nil { fmt.Println(err) os.Exit(1) } // Get updates channel updates, _ := bot.UpdatesViaLongPolling(nil) // Create bot handler and specify from where to get updates bh, _ := th.NewBotHandler(bot, updates) // Stop handling updates defer bh.Stop() // Stop getting updates defer bot.StopLongPolling() // Add global middleware, it will be applied in order of addition bh.Use( func(bot *telego.Bot, update telego.Update, next th.Handler) { fmt.Println("Global middleware") // Will be called first next(bot, update) }, func(bot *telego.Bot, update telego.Update, next th.Handler) { fmt.Println("Global middleware 2") // Will be called second next(bot, update) }, ) // Create any groups with or without predicates // Note: Updates first checked by groups and only then by handlers (group -> ... -> group -> handler) task := bh.Group(th.TextContains("task")) // Add middleware to groups task.Use(func(bot *telego.Bot, update telego.Update, next th.Handler) { fmt.Println("Group based middleware") // Will be called third if len(update.Message.Text) < 10 { next(bot, update) } }) // Handle updates on a group task.HandleMessage(func(bot *telego.Bot, message telego.Message) { fmt.Println("Task...") // Will be called fourth }) // Start handling updates bh.Start() }
Index ¶
- Constants
- Variables
- type BotHandler
- func (h *BotHandler) BaseGroup() *HandlerGroup
- func (h *BotHandler) Group(predicates ...Predicate) *HandlerGroup
- func (h *BotHandler) Handle(handler Handler, predicates ...Predicate)
- func (h *BotHandler) HandleCallbackQuery(handler CallbackQueryHandler, predicates ...Predicate)
- func (h *BotHandler) HandleCallbackQueryCtx(handler CallbackQueryHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleChannelPost(handler MessageHandler, predicates ...Predicate)
- func (h *BotHandler) HandleChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleChatJoinRequest(handler ChatJoinRequestHandler, predicates ...Predicate)
- func (h *BotHandler) HandleChatJoinRequestCtx(handler ChatJoinRequestHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
- func (h *BotHandler) HandleChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleChosenInlineResult(handler ChosenInlineResultHandler, predicates ...Predicate)
- func (h *BotHandler) HandleChosenInlineResultCtx(handler ChosenInlineResultHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleEditedChannelPost(handler MessageHandler, predicates ...Predicate)
- func (h *BotHandler) HandleEditedChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleEditedMessage(handler MessageHandler, predicates ...Predicate)
- func (h *BotHandler) HandleEditedMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleInlineQuery(handler InlineQueryHandler, predicates ...Predicate)
- func (h *BotHandler) HandleInlineQueryCtx(handler InlineQueryHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleMessage(handler MessageHandler, predicates ...Predicate)
- func (h *BotHandler) HandleMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleMyChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
- func (h *BotHandler) HandleMyChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandlePoll(handler PollHandler, predicates ...Predicate)
- func (h *BotHandler) HandlePollAnswer(handler PollAnswerHandler, predicates ...Predicate)
- func (h *BotHandler) HandlePollAnswerCtx(handler PollAnswerHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandlePollCtx(handler PollHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandlePreCheckoutQuery(handler PreCheckoutQueryHandler, predicates ...Predicate)
- func (h *BotHandler) HandlePreCheckoutQueryCtx(handler PreCheckoutQueryHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) HandleShippingQuery(handler ShippingQueryHandler, predicates ...Predicate)
- func (h *BotHandler) HandleShippingQueryCtx(handler ShippingQueryHandlerCtx, predicates ...Predicate)
- func (h *BotHandler) IsRunning() bool
- func (h *BotHandler) Start()
- func (h *BotHandler) Stop()
- func (h *BotHandler) StopWithContext(ctx context.Context)
- func (h *BotHandler) Use(middlewares ...Middleware)
- type BotHandlerOption
- type CallbackQueryHandler
- type CallbackQueryHandlerCtx
- type ChatJoinRequestHandler
- type ChatJoinRequestHandlerCtx
- type ChatMemberUpdatedHandler
- type ChatMemberUpdatedHandlerCtx
- type ChosenInlineResultHandler
- type ChosenInlineResultHandlerCtx
- type Handler
- type HandlerGroup
- func (h *HandlerGroup) Group(predicates ...Predicate) *HandlerGroup
- func (h *HandlerGroup) Handle(handler Handler, predicates ...Predicate)
- func (h *HandlerGroup) HandleCallbackQuery(handler CallbackQueryHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleCallbackQueryCtx(handler CallbackQueryHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleChannelPost(handler MessageHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleChatJoinRequest(handler ChatJoinRequestHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleChatJoinRequestCtx(handler ChatJoinRequestHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleChosenInlineResult(handler ChosenInlineResultHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleChosenInlineResultCtx(handler ChosenInlineResultHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleEditedChannelPost(handler MessageHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleEditedChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleEditedMessage(handler MessageHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleEditedMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleInlineQuery(handler InlineQueryHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleInlineQueryCtx(handler InlineQueryHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleMessage(handler MessageHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleMyChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleMyChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandlePoll(handler PollHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandlePollAnswer(handler PollAnswerHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandlePollAnswerCtx(handler PollAnswerHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandlePollCtx(handler PollHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandlePreCheckoutQuery(handler PreCheckoutQueryHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandlePreCheckoutQueryCtx(handler PreCheckoutQueryHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) HandleShippingQuery(handler ShippingQueryHandler, predicates ...Predicate)
- func (h *HandlerGroup) HandleShippingQueryCtx(handler ShippingQueryHandlerCtx, predicates ...Predicate)
- func (h *HandlerGroup) Use(middlewares ...Middleware)
- type InlineQueryHandler
- type InlineQueryHandlerCtx
- type MessageHandler
- type MessageHandlerCtx
- type Middleware
- type PollAnswerHandler
- type PollAnswerHandlerCtx
- type PollHandler
- type PollHandlerCtx
- type PreCheckoutQueryHandler
- type PreCheckoutQueryHandlerCtx
- type Predicate
- func And(predicates ...Predicate) Predicate
- func Any() Predicate
- func AnyCallbackQuery() Predicate
- func AnyCallbackQueryWithMessage() Predicate
- func AnyCaptionCommand() Predicate
- func AnyChannelPost() Predicate
- func AnyChannelPostWithCaption() Predicate
- func AnyChannelPostWithText() Predicate
- func AnyChatJoinRequest() Predicate
- func AnyChatMember() Predicate
- func AnyChosenInlineResult() Predicate
- func AnyCommand() Predicate
- func AnyEditedChannelPost() Predicate
- func AnyEditedChannelPostWithCaption() Predicate
- func AnyEditedChannelPostWithText() Predicate
- func AnyEditedMessage() Predicate
- func AnyEditedMessageWithCaption() Predicate
- func AnyEditedMessageWithFrom() Predicate
- func AnyEditedMessageWithText() Predicate
- func AnyInlineQuery() Predicate
- func AnyMessage() Predicate
- func AnyMessageWithCaption() Predicate
- func AnyMessageWithFrom() Predicate
- func AnyMessageWithText() Predicate
- func AnyMyChatMember() Predicate
- func AnyPoll() Predicate
- func AnyPollAnswer() Predicate
- func AnyPreCheckoutQuery() Predicate
- func AnyShippingQuery() Predicate
- func CallbackDataContains(text string) Predicate
- func CallbackDataEqual(text string) Predicate
- func CallbackDataEqualFold(text string) Predicate
- func CallbackDataMatches(pattern *regexp.Regexp) Predicate
- func CallbackDataPrefix(prefix string) Predicate
- func CallbackDataSuffix(suffix string) Predicate
- func CaptionCommandEqual(command string) Predicate
- func CaptionCommandEqualArgc(command string, argc int) Predicate
- func CaptionCommandEqualArgv(command string, argv ...string) Predicate
- func CaptionContains(text string) Predicate
- func CaptionEqual(text string) Predicate
- func CaptionEqualFold(text string) Predicate
- func CaptionMatches(pattern *regexp.Regexp) Predicate
- func CaptionPrefix(prefix string) Predicate
- func CaptionSuffix(suffix string) Predicate
- func CommandEqual(command string) Predicate
- func CommandEqualArgc(command string, argc int) Predicate
- func CommandEqualArgv(command string, argv ...string) Predicate
- func EditedCaptionContains(text string) Predicate
- func EditedCaptionEqual(text string) Predicate
- func EditedCaptionEqualFold(text string) Predicate
- func EditedCaptionMatches(pattern *regexp.Regexp) Predicate
- func EditedCaptionPrefix(prefix string) Predicate
- func EditedCaptionSuffix(suffix string) Predicate
- func EditedPostCaptionContains(text string) Predicate
- func EditedPostCaptionEqual(text string) Predicate
- func EditedPostCaptionEqualFold(text string) Predicate
- func EditedPostCaptionMatches(pattern *regexp.Regexp) Predicate
- func EditedPostCaptionPrefix(prefix string) Predicate
- func EditedPostCaptionSuffix(suffix string) Predicate
- func EditedPostTextContains(text string) Predicate
- func EditedPostTextEqual(text string) Predicate
- func EditedPostTextEqualFold(text string) Predicate
- func EditedPostTextMatches(pattern *regexp.Regexp) Predicate
- func EditedPostTextPrefix(prefix string) Predicate
- func EditedPostTextSuffix(suffix string) Predicate
- func EditedTextContains(text string) Predicate
- func EditedTextEqual(text string) Predicate
- func EditedTextEqualFold(text string) Predicate
- func EditedTextMatches(pattern *regexp.Regexp) Predicate
- func EditedTextPrefix(prefix string) Predicate
- func EditedTextSuffix(suffix string) Predicate
- func InlineQueryContains(text string) Predicate
- func InlineQueryEqual(text string) Predicate
- func InlineQueryEqualFold(text string) Predicate
- func InlineQueryMatches(pattern *regexp.Regexp) Predicate
- func InlineQueryPrefix(prefix string) Predicate
- func InlineQuerySuffix(suffix string) Predicate
- func None() Predicate
- func Not(predicate Predicate) Predicate
- func Or(predicates ...Predicate) Predicate
- func PostCaptionContains(text string) Predicate
- func PostCaptionEqual(text string) Predicate
- func PostCaptionEqualFold(text string) Predicate
- func PostCaptionMatches(pattern *regexp.Regexp) Predicate
- func PostCaptionPrefix(prefix string) Predicate
- func PostCaptionSuffix(suffix string) Predicate
- func PostTextContains(text string) Predicate
- func PostTextEqual(text string) Predicate
- func PostTextEqualFold(text string) Predicate
- func PostTextMatches(pattern *regexp.Regexp) Predicate
- func PostTextPrefix(prefix string) Predicate
- func PostTextSuffix(suffix string) Predicate
- func SuccessPayment() Predicate
- func TextContains(text string) Predicate
- func TextEqual(text string) Predicate
- func TextEqualFold(text string) Predicate
- func TextMatches(pattern *regexp.Regexp) Predicate
- func TextPrefix(prefix string) Predicate
- func TextSuffix(suffix string) Predicate
- func Union(predicates ...Predicate) Predicatedeprecated
- type ShippingQueryHandler
- type ShippingQueryHandlerCtx
Constants ¶
const ( CommandMatchCmdGroup = 1 CommandMatchBotUsernameGroup = 2 CommandMatchArgsGroup = 3 )
Command match group indexes in the CommandRegexp
const CommandMatchGroupsLen = 4
CommandMatchGroupsLen represents the length of match groups in the CommandRegexp
Variables ¶
var CommandRegexp = regexp.MustCompile(`(?s)^/(\w+)(@\w+)?(?:\s+(.+?)\s*)?$`)
CommandRegexp matches to command and has match groups on command, bot username and arguments
Functions ¶
This section is empty.
Types ¶
type BotHandler ¶
type BotHandler struct {
// contains filtered or unexported fields
}
BotHandler represents a bot handler that can handle updated matching by predicates
func NewBotHandler ¶
func NewBotHandler(bot *telego.Bot, updates <-chan telego.Update, options ...BotHandlerOption) (*BotHandler, error)
NewBotHandler creates new bot handler
func (*BotHandler) BaseGroup ¶ added in v0.26.0
func (h *BotHandler) BaseGroup() *HandlerGroup
BaseGroup returns a base group that is used by default in BotHandler methods
func (*BotHandler) Group ¶ added in v0.21.0
func (h *BotHandler) Group(predicates ...Predicate) *HandlerGroup
Group creates a new group of handlers and middlewares from the base group Note: Updates first checked by group and only after that by handler
Warning: Panics if nil predicates passed
func (*BotHandler) Handle ¶
func (h *BotHandler) Handle(handler Handler, predicates ...Predicate)
Handle registers new handler in the base group, update will be processed only by first-matched handler, order of registration determines the order of matching handlers. Important to notice, update's context will be automatically canceled once the handler will finish processing or the bot handler stopped. Note: All handlers will process updates in parallel, there is no guaranty on order of processed updates, also keep in mind that middlewares and predicates are checked sequentially.
Warning: Panics if nil handler or predicates passed
func (*BotHandler) HandleCallbackQuery ¶ added in v0.10.4
func (h *BotHandler) HandleCallbackQuery(handler CallbackQueryHandler, predicates ...Predicate)
HandleCallbackQuery same as Handle, but assumes that the update contains a callback query
func (*BotHandler) HandleCallbackQueryCtx ¶ added in v0.27.0
func (h *BotHandler) HandleCallbackQueryCtx(handler CallbackQueryHandlerCtx, predicates ...Predicate)
HandleCallbackQueryCtx same as Handle, but assumes that the update contains a callback query
func (*BotHandler) HandleChannelPost ¶ added in v0.11.1
func (h *BotHandler) HandleChannelPost(handler MessageHandler, predicates ...Predicate)
HandleChannelPost same as Handle, but assumes that the update contains a channel post
func (*BotHandler) HandleChannelPostCtx ¶ added in v0.27.0
func (h *BotHandler) HandleChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleChannelPostCtx same as Handle, but assumes that the update contains a channel post
func (*BotHandler) HandleChatJoinRequest ¶ added in v0.11.1
func (h *BotHandler) HandleChatJoinRequest(handler ChatJoinRequestHandler, predicates ...Predicate)
HandleChatJoinRequest same as Handle, but assumes that the update contains chat join request
func (*BotHandler) HandleChatJoinRequestCtx ¶ added in v0.27.0
func (h *BotHandler) HandleChatJoinRequestCtx(handler ChatJoinRequestHandlerCtx, predicates ...Predicate)
HandleChatJoinRequestCtx same as Handle, but assumes that the update contains chat join request
func (*BotHandler) HandleChatMemberUpdated ¶ added in v0.11.1
func (h *BotHandler) HandleChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
HandleChatMemberUpdated same as Handle, but assumes that the update contains chat member
func (*BotHandler) HandleChatMemberUpdatedCtx ¶ added in v0.27.0
func (h *BotHandler) HandleChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
HandleChatMemberUpdatedCtx same as Handle, but assumes that the update contains chat member
func (*BotHandler) HandleChosenInlineResult ¶ added in v0.11.1
func (h *BotHandler) HandleChosenInlineResult(handler ChosenInlineResultHandler, predicates ...Predicate)
HandleChosenInlineResult same as Handle, but assumes that the update contains a chosen inline result
func (*BotHandler) HandleChosenInlineResultCtx ¶ added in v0.27.0
func (h *BotHandler) HandleChosenInlineResultCtx(handler ChosenInlineResultHandlerCtx, predicates ...Predicate)
HandleChosenInlineResultCtx same as Handle, but assumes that the update contains a chosen inline result
func (*BotHandler) HandleEditedChannelPost ¶ added in v0.11.1
func (h *BotHandler) HandleEditedChannelPost(handler MessageHandler, predicates ...Predicate)
HandleEditedChannelPost same as Handle, but assumes that the update contains an edited channel post
func (*BotHandler) HandleEditedChannelPostCtx ¶ added in v0.27.0
func (h *BotHandler) HandleEditedChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleEditedChannelPostCtx same as Handle, but assumes that the update contains an edited channel post
func (*BotHandler) HandleEditedMessage ¶ added in v0.11.1
func (h *BotHandler) HandleEditedMessage(handler MessageHandler, predicates ...Predicate)
HandleEditedMessage same as Handle, but assumes that the update contains an edited message
func (*BotHandler) HandleEditedMessageCtx ¶ added in v0.27.0
func (h *BotHandler) HandleEditedMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleEditedMessageCtx same as Handle, but assumes that the update contains an edited message
func (*BotHandler) HandleInlineQuery ¶ added in v0.11.1
func (h *BotHandler) HandleInlineQuery(handler InlineQueryHandler, predicates ...Predicate)
HandleInlineQuery same as Handle, but assumes that the update contains an inline query
func (*BotHandler) HandleInlineQueryCtx ¶ added in v0.27.0
func (h *BotHandler) HandleInlineQueryCtx(handler InlineQueryHandlerCtx, predicates ...Predicate)
HandleInlineQueryCtx same as Handle, but assumes that the update contains an inline query
func (*BotHandler) HandleMessage ¶ added in v0.10.3
func (h *BotHandler) HandleMessage(handler MessageHandler, predicates ...Predicate)
HandleMessage same as Handle, but assumes that the update contains a message
func (*BotHandler) HandleMessageCtx ¶ added in v0.27.0
func (h *BotHandler) HandleMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleMessageCtx same as Handle, but assumes that the update contains a message
func (*BotHandler) HandleMyChatMemberUpdated ¶ added in v0.11.1
func (h *BotHandler) HandleMyChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
HandleMyChatMemberUpdated same as Handle, but assumes that the update contains my chat member
func (*BotHandler) HandleMyChatMemberUpdatedCtx ¶ added in v0.27.0
func (h *BotHandler) HandleMyChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
HandleMyChatMemberUpdatedCtx same as Handle, but assumes that the update contains my chat member
func (*BotHandler) HandlePoll ¶ added in v0.11.1
func (h *BotHandler) HandlePoll(handler PollHandler, predicates ...Predicate)
HandlePoll same as Handle, but assumes that the update contains a poll
func (*BotHandler) HandlePollAnswer ¶ added in v0.11.1
func (h *BotHandler) HandlePollAnswer(handler PollAnswerHandler, predicates ...Predicate)
HandlePollAnswer same as Handle, but assumes that the update contains a poll answer
func (*BotHandler) HandlePollAnswerCtx ¶ added in v0.27.0
func (h *BotHandler) HandlePollAnswerCtx(handler PollAnswerHandlerCtx, predicates ...Predicate)
HandlePollAnswerCtx same as Handle, but assumes that the update contains a poll answer
func (*BotHandler) HandlePollCtx ¶ added in v0.27.0
func (h *BotHandler) HandlePollCtx(handler PollHandlerCtx, predicates ...Predicate)
HandlePollCtx same as Handle, but assumes that the update contains a poll
func (*BotHandler) HandlePreCheckoutQuery ¶ added in v0.11.1
func (h *BotHandler) HandlePreCheckoutQuery(handler PreCheckoutQueryHandler, predicates ...Predicate)
HandlePreCheckoutQuery same as Handle, but assumes that the update contains a pre checkout query
func (*BotHandler) HandlePreCheckoutQueryCtx ¶ added in v0.27.0
func (h *BotHandler) HandlePreCheckoutQueryCtx(handler PreCheckoutQueryHandlerCtx, predicates ...Predicate)
HandlePreCheckoutQueryCtx same as Handle, but assumes that the update contains a pre checkout query
func (*BotHandler) HandleShippingQuery ¶ added in v0.11.1
func (h *BotHandler) HandleShippingQuery(handler ShippingQueryHandler, predicates ...Predicate)
HandleShippingQuery same as Handle, but assumes that the update contains a shipping query
func (*BotHandler) HandleShippingQueryCtx ¶ added in v0.27.0
func (h *BotHandler) HandleShippingQueryCtx(handler ShippingQueryHandlerCtx, predicates ...Predicate)
HandleShippingQueryCtx same as Handle, but assumes that the update contains a shipping query
func (*BotHandler) IsRunning ¶ added in v0.9.1
func (h *BotHandler) IsRunning() bool
IsRunning tells if Start is running
func (*BotHandler) Start ¶
func (h *BotHandler) Start()
Start starts handling of updates, blocks execution Note: Calling BotHandler.Start method multiple times after the first one does nothing.
func (*BotHandler) Stop ¶
func (h *BotHandler) Stop()
Stop stops handling of updates, will block until all updates have been processes. It's recommended to use BotHandler.StopWithContext if you want to force stop after some timeout.
func (*BotHandler) StopWithContext ¶ added in v0.30.0
func (h *BotHandler) StopWithContext(ctx context.Context)
StopWithContext stops handling of updates, blocks until all updates have been processes or when context is canceled. Note: Calling BotHandler.StopWithContext method multiple times or before BotHandler.Start does nothing.
func (*BotHandler) Use ¶ added in v0.21.0
func (h *BotHandler) Use(middlewares ...Middleware)
Use applies middleware to the base group Note: The chain will be stopped if middleware doesn't call the next func, if there is no context timeout then update will be stuck, if there is time out then the group will be skipped since not all middlewares were called
Warning: Panics if nil middlewares passed
type BotHandlerOption ¶ added in v0.13.0
type BotHandlerOption func(bh *BotHandler) error
BotHandlerOption represents an option that can be applied to bot handler
type CallbackQueryHandler ¶ added in v0.10.4
type CallbackQueryHandler func(bot *telego.Bot, query telego.CallbackQuery)
CallbackQueryHandler handles callback queries that came from bot
type CallbackQueryHandlerCtx ¶ added in v0.27.0
CallbackQueryHandlerCtx handles callback queries that came from bot with context
type ChatJoinRequestHandler ¶ added in v0.11.1
type ChatJoinRequestHandler func(bot *telego.Bot, request telego.ChatJoinRequest)
ChatJoinRequestHandler handles chat join request that came from bot
type ChatJoinRequestHandlerCtx ¶ added in v0.27.0
type ChatJoinRequestHandlerCtx func(ctx context.Context, bot *telego.Bot, request telego.ChatJoinRequest)
ChatJoinRequestHandlerCtx handles chat join request that came from bot with context
type ChatMemberUpdatedHandler ¶ added in v0.11.1
type ChatMemberUpdatedHandler func(bot *telego.Bot, chatMember telego.ChatMemberUpdated)
ChatMemberUpdatedHandler handles chat member that came from bot
type ChatMemberUpdatedHandlerCtx ¶ added in v0.27.0
type ChatMemberUpdatedHandlerCtx func(ctx context.Context, bot *telego.Bot, chatMember telego.ChatMemberUpdated)
ChatMemberUpdatedHandlerCtx handles chat member that came from bot with context
type ChosenInlineResultHandler ¶ added in v0.11.1
type ChosenInlineResultHandler func(bot *telego.Bot, result telego.ChosenInlineResult)
ChosenInlineResultHandler handles chosen inline result that came from bot
type ChosenInlineResultHandlerCtx ¶ added in v0.27.0
type ChosenInlineResultHandlerCtx func(ctx context.Context, bot *telego.Bot, result telego.ChosenInlineResult)
ChosenInlineResultHandlerCtx handles chosen inline result that came from bot with context
type HandlerGroup ¶ added in v0.21.0
type HandlerGroup struct {
// contains filtered or unexported fields
}
HandlerGroup represents a group of handlers, middlewares and child groups
func (*HandlerGroup) Group ¶ added in v0.21.0
func (h *HandlerGroup) Group(predicates ...Predicate) *HandlerGroup
Group creates a new group of handlers and middlewares from the parent group Note: Updates first checked by group and only after that by handler
Warning: Panics if nil predicates passed
func (*HandlerGroup) Handle ¶ added in v0.21.0
func (h *HandlerGroup) Handle(handler Handler, predicates ...Predicate)
Handle registers new handler in the group, update will be processed only by first-matched handler, order of registration determines the order of matching handlers. Important to notice, update's context will be automatically canceled once the handler will finish processing or the bot handler stopped. Note: All handlers will process updates in parallel, there is no guaranty on order of processed updates, also keep in mind that middlewares and predicates are checked sequentially.
Warning: Panics if nil handler or predicates passed
func (*HandlerGroup) HandleCallbackQuery ¶ added in v0.21.0
func (h *HandlerGroup) HandleCallbackQuery(handler CallbackQueryHandler, predicates ...Predicate)
HandleCallbackQuery same as Handle, but assumes that the update contains a callback query
func (*HandlerGroup) HandleCallbackQueryCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleCallbackQueryCtx(handler CallbackQueryHandlerCtx, predicates ...Predicate)
HandleCallbackQueryCtx same as Handle, but assumes that the update contains a callback query
func (*HandlerGroup) HandleChannelPost ¶ added in v0.21.0
func (h *HandlerGroup) HandleChannelPost(handler MessageHandler, predicates ...Predicate)
HandleChannelPost same as Handle, but assumes that the update contains a channel post
func (*HandlerGroup) HandleChannelPostCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleChannelPostCtx same as Handle, but assumes that the update contains a channel post
func (*HandlerGroup) HandleChatJoinRequest ¶ added in v0.21.0
func (h *HandlerGroup) HandleChatJoinRequest(handler ChatJoinRequestHandler, predicates ...Predicate)
HandleChatJoinRequest same as Handle, but assumes that the update contains chat join request
func (*HandlerGroup) HandleChatJoinRequestCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleChatJoinRequestCtx(handler ChatJoinRequestHandlerCtx, predicates ...Predicate)
HandleChatJoinRequestCtx same as Handle, but assumes that the update contains chat join request
func (*HandlerGroup) HandleChatMemberUpdated ¶ added in v0.21.0
func (h *HandlerGroup) HandleChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
HandleChatMemberUpdated same as Handle, but assumes that the update contains chat member
func (*HandlerGroup) HandleChatMemberUpdatedCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
HandleChatMemberUpdatedCtx same as Handle, but assumes that the update contains chat member
func (*HandlerGroup) HandleChosenInlineResult ¶ added in v0.21.0
func (h *HandlerGroup) HandleChosenInlineResult(handler ChosenInlineResultHandler, predicates ...Predicate)
HandleChosenInlineResult same as Handle, but assumes that the update contains a chosen inline result
func (*HandlerGroup) HandleChosenInlineResultCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleChosenInlineResultCtx(handler ChosenInlineResultHandlerCtx, predicates ...Predicate)
HandleChosenInlineResultCtx same as Handle, but assumes that the update contains a chosen inline result
func (*HandlerGroup) HandleEditedChannelPost ¶ added in v0.21.0
func (h *HandlerGroup) HandleEditedChannelPost(handler MessageHandler, predicates ...Predicate)
HandleEditedChannelPost same as Handle, but assumes that the update contains an edited channel post
func (*HandlerGroup) HandleEditedChannelPostCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleEditedChannelPostCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleEditedChannelPostCtx same as Handle, but assumes that the update contains an edited channel post
func (*HandlerGroup) HandleEditedMessage ¶ added in v0.21.0
func (h *HandlerGroup) HandleEditedMessage(handler MessageHandler, predicates ...Predicate)
HandleEditedMessage same as Handle, but assumes that the update contains an edited message
func (*HandlerGroup) HandleEditedMessageCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleEditedMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleEditedMessageCtx same as Handle, but assumes that the update contains an edited message
func (*HandlerGroup) HandleInlineQuery ¶ added in v0.21.0
func (h *HandlerGroup) HandleInlineQuery(handler InlineQueryHandler, predicates ...Predicate)
HandleInlineQuery same as Handle, but assumes that the update contains an inline query
func (*HandlerGroup) HandleInlineQueryCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleInlineQueryCtx(handler InlineQueryHandlerCtx, predicates ...Predicate)
HandleInlineQueryCtx same as Handle, but assumes that the update contains an inline query
func (*HandlerGroup) HandleMessage ¶ added in v0.21.0
func (h *HandlerGroup) HandleMessage(handler MessageHandler, predicates ...Predicate)
HandleMessage same as Handle, but assumes that the update contains a message
func (*HandlerGroup) HandleMessageCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleMessageCtx(handler MessageHandlerCtx, predicates ...Predicate)
HandleMessageCtx same as Handle, but assumes that the update contains a message
func (*HandlerGroup) HandleMyChatMemberUpdated ¶ added in v0.21.0
func (h *HandlerGroup) HandleMyChatMemberUpdated(handler ChatMemberUpdatedHandler, predicates ...Predicate)
HandleMyChatMemberUpdated same as Handle, but assumes that the update contains my chat member
func (*HandlerGroup) HandleMyChatMemberUpdatedCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleMyChatMemberUpdatedCtx(handler ChatMemberUpdatedHandlerCtx, predicates ...Predicate)
HandleMyChatMemberUpdatedCtx same as Handle, but assumes that the update contains my chat member
func (*HandlerGroup) HandlePoll ¶ added in v0.21.0
func (h *HandlerGroup) HandlePoll(handler PollHandler, predicates ...Predicate)
HandlePoll same as Handle, but assumes that the update contains a poll
func (*HandlerGroup) HandlePollAnswer ¶ added in v0.21.0
func (h *HandlerGroup) HandlePollAnswer(handler PollAnswerHandler, predicates ...Predicate)
HandlePollAnswer same as Handle, but assumes that the update contains a poll answer
func (*HandlerGroup) HandlePollAnswerCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandlePollAnswerCtx(handler PollAnswerHandlerCtx, predicates ...Predicate)
HandlePollAnswerCtx same as Handle, but assumes that the update contains a poll answer
func (*HandlerGroup) HandlePollCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandlePollCtx(handler PollHandlerCtx, predicates ...Predicate)
HandlePollCtx same as Handle, but assumes that the update contains a poll
func (*HandlerGroup) HandlePreCheckoutQuery ¶ added in v0.21.0
func (h *HandlerGroup) HandlePreCheckoutQuery(handler PreCheckoutQueryHandler, predicates ...Predicate)
HandlePreCheckoutQuery same as Handle, but assumes that the update contains a pre checkout query
func (*HandlerGroup) HandlePreCheckoutQueryCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandlePreCheckoutQueryCtx(handler PreCheckoutQueryHandlerCtx, predicates ...Predicate)
HandlePreCheckoutQueryCtx same as Handle, but assumes that the update contains a pre checkout query
func (*HandlerGroup) HandleShippingQuery ¶ added in v0.21.0
func (h *HandlerGroup) HandleShippingQuery(handler ShippingQueryHandler, predicates ...Predicate)
HandleShippingQuery same as Handle, but assumes that the update contains a shipping query
func (*HandlerGroup) HandleShippingQueryCtx ¶ added in v0.27.0
func (h *HandlerGroup) HandleShippingQueryCtx(handler ShippingQueryHandlerCtx, predicates ...Predicate)
HandleShippingQueryCtx same as Handle, but assumes that the update contains a shipping query
func (*HandlerGroup) Use ¶ added in v0.21.0
func (h *HandlerGroup) Use(middlewares ...Middleware)
Use applies middleware to the group Note: The chain will be stopped if middleware doesn't call the next func, if there is no context timeout then update will be stuck, if there is time out then the group will be skipped since not all middlewares were called
Warning: Panics if nil middlewares passed
type InlineQueryHandler ¶ added in v0.11.1
type InlineQueryHandler func(bot *telego.Bot, query telego.InlineQuery)
InlineQueryHandler handles inline queries that came from bot
type InlineQueryHandlerCtx ¶ added in v0.27.0
InlineQueryHandlerCtx handles inline queries that came from bot with context
type MessageHandler ¶ added in v0.10.3
MessageHandler handles message that came from bot
type MessageHandlerCtx ¶ added in v0.27.0
MessageHandlerCtx handles message that came from bot with context
type Middleware ¶ added in v0.21.0
Middleware applies any function on bot and update before calling other middlewares, predicates and handler Note: Calling next multiple times does nothing after first call, calling next in goroutine is allowed, but user should expect that context will be closed sooner than handler ends
Warning: Not calling next at all is allowed, but if context doesn't close, update will be stuck forever, however if context closes since not all middlewares were executed, the handler group will be skipped
func PanicRecovery ¶ added in v0.21.0
func PanicRecovery() Middleware
PanicRecovery returns a middleware that will recover handler from panic Note: It's not recommend to ignore panics, use PanicRecoveryHandler instead to handle them
func PanicRecoveryHandler ¶ added in v0.27.0
func PanicRecoveryHandler(panicHandler func(recovered any)) Middleware
PanicRecoveryHandler returns a middleware that will recover handler from panic and call panic handler
func Timeout ¶ added in v0.27.0
func Timeout(timeout time.Duration) Middleware
Timeout returns a middleware that will add timeout to context
type PollAnswerHandler ¶ added in v0.11.1
type PollAnswerHandler func(bot *telego.Bot, answer telego.PollAnswer)
PollAnswerHandler handles poll answer that came from bot
type PollAnswerHandlerCtx ¶ added in v0.27.0
PollAnswerHandlerCtx handles poll answer that came from bot with context
type PollHandler ¶ added in v0.11.1
PollHandler handles poll that came from bot
type PollHandlerCtx ¶ added in v0.27.0
PollHandlerCtx handles poll that came from bot with context
type PreCheckoutQueryHandler ¶ added in v0.11.1
type PreCheckoutQueryHandler func(bot *telego.Bot, query telego.PreCheckoutQuery)
PreCheckoutQueryHandler handles pre checkout query that came from bot
type PreCheckoutQueryHandlerCtx ¶ added in v0.27.0
type PreCheckoutQueryHandlerCtx func(ctx context.Context, bot *telego.Bot, query telego.PreCheckoutQuery)
PreCheckoutQueryHandlerCtx handles pre checkout query that came from bot with context
type Predicate ¶
Predicate allows filtering updates for handlers Note: Predicate can't change the update, because it uses a copy, not original value
func AnyCallbackQuery ¶ added in v0.10.4
func AnyCallbackQuery() Predicate
AnyCallbackQuery is true if the callback query isn't nil
func AnyCallbackQueryWithMessage ¶ added in v0.10.4
func AnyCallbackQueryWithMessage() Predicate
AnyCallbackQueryWithMessage is true if callback query and its message isn't nil
func AnyCaptionCommand ¶ added in v0.26.1
func AnyCaptionCommand() Predicate
AnyCaptionCommand is true if the message isn't nil, and its caption matches to command regexp
func AnyChannelPost ¶ added in v0.11.1
func AnyChannelPost() Predicate
AnyChannelPost is true if channel post isn't nil
func AnyChannelPostWithCaption ¶ added in v0.26.1
func AnyChannelPostWithCaption() Predicate
AnyChannelPostWithCaption is true if channel post isn't nil and its caption is not empty
func AnyChannelPostWithText ¶ added in v0.13.0
func AnyChannelPostWithText() Predicate
AnyChannelPostWithText is true if channel post isn't nil and its text is not empty
func AnyChatJoinRequest ¶ added in v0.11.1
func AnyChatJoinRequest() Predicate
AnyChatJoinRequest is true if chat join request isn't nil
func AnyChatMember ¶ added in v0.11.1
func AnyChatMember() Predicate
AnyChatMember is true if chat member isn't nil
func AnyChosenInlineResult ¶ added in v0.11.1
func AnyChosenInlineResult() Predicate
AnyChosenInlineResult is true if the chosen inline result isn't nil
func AnyCommand ¶ added in v0.10.1
func AnyCommand() Predicate
AnyCommand is true if the message isn't nil, and it matches to command regexp
func AnyEditedChannelPost ¶ added in v0.11.1
func AnyEditedChannelPost() Predicate
AnyEditedChannelPost is true if the edited channel post isn't nil
func AnyEditedChannelPostWithCaption ¶ added in v0.26.1
func AnyEditedChannelPostWithCaption() Predicate
AnyEditedChannelPostWithCaption is true if edited channel post isn't nil and its caption is not empty
func AnyEditedChannelPostWithText ¶ added in v0.13.0
func AnyEditedChannelPostWithText() Predicate
AnyEditedChannelPostWithText is true if edited channel post isn't nil and its text is not empty
func AnyEditedMessage ¶ added in v0.11.1
func AnyEditedMessage() Predicate
AnyEditedMessage is true if the edited message isn't nil
func AnyEditedMessageWithCaption ¶ added in v0.26.1
func AnyEditedMessageWithCaption() Predicate
AnyEditedMessageWithCaption is true if the edited message isn't nil and its caption is not empty
func AnyEditedMessageWithFrom ¶ added in v0.26.0
func AnyEditedMessageWithFrom() Predicate
AnyEditedMessageWithFrom is true if the edited message isn't nil and its from (sender) is not nil
func AnyEditedMessageWithText ¶ added in v0.13.0
func AnyEditedMessageWithText() Predicate
AnyEditedMessageWithText is true if the edited message isn't nil and its text is not empty
func AnyInlineQuery ¶ added in v0.11.1
func AnyInlineQuery() Predicate
AnyInlineQuery is true if inline query isn't nil
func AnyMessage ¶ added in v0.10.3
func AnyMessage() Predicate
AnyMessage is true if the message isn't nil
func AnyMessageWithCaption ¶ added in v0.26.1
func AnyMessageWithCaption() Predicate
AnyMessageWithCaption is true if the message isn't nil and its caption is not empty
func AnyMessageWithFrom ¶ added in v0.26.0
func AnyMessageWithFrom() Predicate
AnyMessageWithFrom is true if the message isn't nil and its from (sender) is not nil
func AnyMessageWithText ¶ added in v0.13.0
func AnyMessageWithText() Predicate
AnyMessageWithText is true if the message isn't nil and its text is not empty
func AnyMyChatMember ¶ added in v0.11.1
func AnyMyChatMember() Predicate
AnyMyChatMember is true if my chat member isn't nil
func AnyPollAnswer ¶ added in v0.11.1
func AnyPollAnswer() Predicate
AnyPollAnswer is true if the poll answer isn't nil
func AnyPreCheckoutQuery ¶ added in v0.11.1
func AnyPreCheckoutQuery() Predicate
AnyPreCheckoutQuery is true if the pre checkout query isn't nil
func AnyShippingQuery ¶ added in v0.11.1
func AnyShippingQuery() Predicate
AnyShippingQuery is true if shipping query isn't nil
func CallbackDataContains ¶ added in v0.10.4
CallbackDataContains is true if the callback query isn't nil, and its data contains specified text
func CallbackDataEqual ¶ added in v0.10.4
CallbackDataEqual is true if callback query isn't nil, and its data equal to specified text
func CallbackDataEqualFold ¶ added in v0.10.4
CallbackDataEqualFold is true if the callback query isn't nil, and its data equal fold (more general form of case-insensitivity equal) to the specified text
func CallbackDataMatches ¶ added in v0.10.4
CallbackDataMatches is true if the callback query isn't nil, and its data matches specified regexp
func CallbackDataPrefix ¶ added in v0.10.4
CallbackDataPrefix is true if the callback query isn't nil, and its data has specified prefix
func CallbackDataSuffix ¶ added in v0.10.4
CallbackDataSuffix is true if the callback query isn't nil, and its data has specified suffix
func CaptionCommandEqual ¶ added in v0.26.1
CaptionCommandEqual is true if the message isn't nil, and its caption contains specified command
func CaptionCommandEqualArgc ¶ added in v0.26.1
CaptionCommandEqualArgc is true if the message isn't nil, and its caption contains specified command with a number of args
func CaptionCommandEqualArgv ¶ added in v0.26.1
CaptionCommandEqualArgv is true if the message isn't nil, and its caption contains specified command and args
func CaptionContains ¶ added in v0.26.1
CaptionContains is true if the message isn't nil, and its caption contains specified text
func CaptionEqual ¶ added in v0.26.1
CaptionEqual is true if the message isn't nil, and its caption is equal to the specified text
func CaptionEqualFold ¶ added in v0.26.1
CaptionEqualFold is true if the message isn't nil, and its caption equal fold (more general form of case-insensitivity equal) to the specified text
func CaptionMatches ¶ added in v0.26.1
CaptionMatches is true if the message isn't nil, and its caption matches specified regexp
func CaptionPrefix ¶ added in v0.26.1
CaptionPrefix is true if the message isn't nil, and its caption has specified prefix
func CaptionSuffix ¶ added in v0.26.1
CaptionSuffix is true if the message isn't nil, and its caption has specified suffix
func CommandEqual ¶ added in v0.9.1
CommandEqual is true if the message isn't nil, and it contains specified command
func CommandEqualArgc ¶ added in v0.10.1
CommandEqualArgc is true if the message isn't nil, and it contains specified command with a number of args
func CommandEqualArgv ¶ added in v0.10.1
CommandEqualArgv is true if the message isn't nil, and it contains specified command and args
func EditedCaptionContains ¶ added in v0.26.1
EditedCaptionContains is true if the edited message isn't nil, and its caption contains specified text
func EditedCaptionEqual ¶ added in v0.26.1
EditedCaptionEqual is true if the edited message isn't nil, and its caption equals to the specified text
func EditedCaptionEqualFold ¶ added in v0.26.1
EditedCaptionEqualFold is true if the edited message isn't nil, and its caption equal fold (more general form of case-insensitivity equal) to the specified text
func EditedCaptionMatches ¶ added in v0.26.1
EditedCaptionMatches is true if the edited message isn't nil, and its caption matches specified regexp
func EditedCaptionPrefix ¶ added in v0.26.1
EditedCaptionPrefix is true if the edited message isn't nil, and its caption has specified prefix
func EditedCaptionSuffix ¶ added in v0.26.1
EditedCaptionSuffix is true if the edited message isn't nil, and its caption has specified suffix
func EditedPostCaptionContains ¶ added in v0.26.1
EditedPostCaptionContains is true if edited channel post isn't nil, and its caption contains specified text
func EditedPostCaptionEqual ¶ added in v0.26.1
EditedPostCaptionEqual is true if edited channel post isn't nil, and its caption equals to the specified text
func EditedPostCaptionEqualFold ¶ added in v0.26.1
EditedPostCaptionEqualFold is true if edited channel post isn't nil, and its caption equal fold (more general form of case-insensitivity equal) to the specified text
func EditedPostCaptionMatches ¶ added in v0.26.1
EditedPostCaptionMatches is true if edited channel post isn't nil, and its caption matches specified regexp
func EditedPostCaptionPrefix ¶ added in v0.26.1
EditedPostCaptionPrefix is true if edited channel post isn't nil, and its caption has specified prefix
func EditedPostCaptionSuffix ¶ added in v0.26.1
EditedPostCaptionSuffix is true if edited channel post isn't nil, and its caption has specified suffix
func EditedPostTextContains ¶ added in v0.11.1
EditedPostTextContains is true if edited channel post isn't nil, and its text contains specified text
func EditedPostTextEqual ¶ added in v0.11.1
EditedPostTextEqual is true if edited channel post isn't nil, and its text equals to the specified text
func EditedPostTextEqualFold ¶ added in v0.11.1
EditedPostTextEqualFold is true if edited channel post isn't nil, and its text equal fold (more general form of case-insensitivity equal) to the specified text
func EditedPostTextMatches ¶ added in v0.11.1
EditedPostTextMatches is true if edited channel post isn't nil, and its text matches specified regexp
func EditedPostTextPrefix ¶ added in v0.11.1
EditedPostTextPrefix is true if edited channel post isn't nil, and its text has specified prefix
func EditedPostTextSuffix ¶ added in v0.11.1
EditedPostTextSuffix is true if edited channel post isn't nil, and its text has specified suffix
func EditedTextContains ¶ added in v0.11.1
EditedTextContains is true if the edited message isn't nil, and its text contains specified text
func EditedTextEqual ¶ added in v0.11.1
EditedTextEqual is true if the edited message isn't nil, and its text equals to the specified text
func EditedTextEqualFold ¶ added in v0.11.1
EditedTextEqualFold is true if the edited message isn't nil, and its text equal fold (more general form of case-insensitivity equal) to the specified text
func EditedTextMatches ¶ added in v0.11.1
EditedTextMatches is true if the edited message isn't nil, and its text matches specified regexp
func EditedTextPrefix ¶ added in v0.11.1
EditedTextPrefix is true if the edited message isn't nil, and its text has specified prefix
func EditedTextSuffix ¶ added in v0.11.1
EditedTextSuffix is true if the edited message isn't nil, and its text has specified suffix
func InlineQueryContains ¶ added in v0.11.1
InlineQueryContains is true if inline query isn't nil, and its query contains specified text
func InlineQueryEqual ¶ added in v0.11.1
InlineQueryEqual is true if inline query isn't nil, and its query equal to specified text
func InlineQueryEqualFold ¶ added in v0.11.1
InlineQueryEqualFold is true if inline query isn't nil, and its query equal fold (more general form of case-insensitivity equal) to the specified text
func InlineQueryMatches ¶ added in v0.11.1
InlineQueryMatches is true if inline query isn't nil, and its query matches specified regexp
func InlineQueryPrefix ¶ added in v0.11.1
InlineQueryPrefix is true if inline query isn't nil, and its query has specified prefix
func InlineQuerySuffix ¶ added in v0.11.1
InlineQuerySuffix is true if inline query isn't nil, and its query has specified suffix
func PostCaptionContains ¶ added in v0.26.1
PostCaptionContains is true if channel post isn't nil, and its caption contains specified text
func PostCaptionEqual ¶ added in v0.26.1
PostCaptionEqual is true if channel post isn't nil, and its caption equals to the specified text
func PostCaptionEqualFold ¶ added in v0.26.1
PostCaptionEqualFold is true if channel post isn't nil, and its caption equal fold (more general form of case-insensitivity equal) to the specified text
func PostCaptionMatches ¶ added in v0.26.1
PostCaptionMatches is true if channel post isn't nil, and its caption matches specified regexp
func PostCaptionPrefix ¶ added in v0.26.1
PostCaptionPrefix is true if channel post isn't nil, and its caption has specified prefix
func PostCaptionSuffix ¶ added in v0.26.1
PostCaptionSuffix is true if channel post isn't nil, and its caption has specified suffix
func PostTextContains ¶ added in v0.11.1
PostTextContains is true if channel post isn't nil, and its text contains specified text
func PostTextEqual ¶ added in v0.11.1
PostTextEqual is true if channel post isn't nil, and its text equals to the specified text
func PostTextEqualFold ¶ added in v0.11.1
PostTextEqualFold is true if channel post isn't nil, and its text equal fold (more general form of case-insensitivity equal) to the specified text
func PostTextMatches ¶ added in v0.11.1
PostTextMatches is true if channel post isn't nil, and its text matches specified regexp
func PostTextPrefix ¶ added in v0.11.1
PostTextPrefix is true if channel post isn't nil, and its text has specified prefix
func PostTextSuffix ¶ added in v0.11.1
PostTextSuffix is true if channel post isn't nil, and its text has specified suffix
func SuccessPayment ¶ added in v0.16.0
func SuccessPayment() Predicate
SuccessPayment is true if the message isn't nil, and contains success payment
func TextContains ¶ added in v0.10.1
TextContains is true if the message isn't nil, and its text contains specified text
func TextEqual ¶ added in v0.8.1
TextEqual is true if the message isn't nil, and its text is equal to the specified text
func TextEqualFold ¶ added in v0.8.1
TextEqualFold is true if the message isn't nil, and its text equal fold (more general form of case-insensitivity equal) to the specified text
func TextMatches ¶ added in v0.8.1
TextMatches is true if the message isn't nil, and its text matches specified regexp
func TextPrefix ¶ added in v0.10.1
TextPrefix is true if the message isn't nil, and its text has specified prefix
func TextSuffix ¶ added in v0.10.1
TextSuffix is true if the message isn't nil, and its text has specified suffix
type ShippingQueryHandler ¶ added in v0.11.1
type ShippingQueryHandler func(bot *telego.Bot, query telego.ShippingQuery)
ShippingQueryHandler handles shipping query that came from bot
type ShippingQueryHandlerCtx ¶ added in v0.27.0
ShippingQueryHandlerCtx handles shipping query that came from bot with context