-
Hi! I've recently decided to upgrade my small pet project which is basically a simple interface to LLM in a form of a Telegram bot. It was using Telego And now I'm facing a strange problem: all my message handlers stopped working. Here's an example of what I had before upgrade: // Middlewares
bh.Use(b.chatHistory)
bh.Use(b.chatTypeStatsCounter)
// Handlers
bh.Handle(b.startHandler, th.CommandEqual("start"))
bh.Handle(b.summarizeHandler, th.Or(th.CommandEqual("summarize"), th.CommandEqual("s")))
bh.Handle(b.statsHandler, th.CommandEqual("stats"))
bh.Handle(b.helpHandler, th.CommandEqual("help"))
bh.Handle(b.resetHandler, th.CommandEqual("reset"))
bh.Handle(b.textMessageHandler, th.AnyMessageWithText()) Middleware example: func (b *Bot) chatHistory(bot *telego.Bot, update telego.Update, next telegohandler.Handler) {
// ...
} Handler example: func (b *Bot) textMessageHandler(bot *telego.Bot, update telego.Update) {
// ...
} After upgrade I've updated all middlewared and handlers to the new interfaces. First I did that with the same New registration: bh.HandleMessage(b.startHandler, th.CommandEqual("start"))
bh.HandleMessage(b.summarizeHandler, th.Or(th.CommandEqual("summarize"), th.CommandEqual("s")))
bh.HandleMessage(b.statsHandler, th.CommandEqual("stats"))
bh.HandleMessage(b.helpHandler, th.CommandEqual("help"))
bh.HandleMessage(b.resetHandler, th.CommandEqual("reset"))
bh.HandleMessage(b.textMessageHandler, th.AnyMessageWithText()) New middleware example: func (b *Bot) chatTypeStatsCounter(ctx *th.Context, update telego.Update) error {
// ...
} New handler example (moved to func (b *Bot) textMessageHandler(ctx *th.Context, message telego.Message) error {
// ...
} The problem is that my middlewares are working fine, but my handlers are't being called now. I don't think it's related to moving from To be precise, I see logs from both middlewares I registered, so I know that they're being called. But my message handlers are just not being called at all: no logs, no working breakpoints when debugging. I didn't find any update instructions, only some Did some other breaking changes in request matching happen? If it'll be somewhat helpful, here's a PR with changes introducing this problem:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, I looked at your code, the reason why nothing works is that you didn't call |
Beta Was this translation helpful? Give feedback.
Hi, I looked at your code, the reason why nothing works is that you didn't call
ctx.Next
in your middleware, previously you hadnext
as an argument; now it's a method ofctx
. Simply add those calls where needed and it will work