This commit is contained in:
2026-02-12 11:17:23 +03:00
parent 60f09e940a
commit ece131c14a
4 changed files with 34 additions and 56 deletions

23
bot.go
View File

@@ -233,7 +233,6 @@ func (b *Bot) Run() {
return
}
b.logger.Infoln("Executing runners...")
b.ExecRunners()
b.logger.Infoln("Bot running. Press CTRL+C to exit.")
@@ -247,33 +246,17 @@ func (b *Bot) Run() {
}()
for {
queue := b.updateQueue
if queue.IsEmpty() {
if b.updateQueue.IsEmpty() {
time.Sleep(time.Millisecond * 25)
continue
}
u := queue.Dequeue()
u := b.updateQueue.Dequeue()
if u == nil {
b.logger.Errorln("update is nil")
continue
}
ctx := &MsgContext{Bot: b, Update: u, Api: b.api}
for _, middleware := range b.middlewares {
middleware.Execute(ctx, b.dbContext)
}
for _, plugin := range b.plugins {
if plugin.UpdateListener != nil {
(*plugin.UpdateListener)(ctx, b.dbContext)
}
}
if u.CallbackQuery != nil {
b.handleCallback(u, ctx)
} else {
b.handleMessage(u, ctx)
}
b.handle(u)
}
}