Trying to fix #13. Adding logging to the middleware.
This commit is contained in:
parent
5f55cec0e2
commit
a2a37d0256
|
@ -3,15 +3,22 @@ package bot
|
||||||
import (
|
import (
|
||||||
"github.com/mymmrac/telego"
|
"github.com/mymmrac/telego"
|
||||||
"github.com/mymmrac/telego/telegohandler"
|
"github.com/mymmrac/telego/telegohandler"
|
||||||
|
"log/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *Bot) chatTypeStatsCounter(bot *telego.Bot, update telego.Update, next telegohandler.Handler) {
|
func (b *Bot) chatTypeStatsCounter(bot *telego.Bot, update telego.Update, next telegohandler.Handler) {
|
||||||
message := update.Message
|
message := update.Message
|
||||||
|
|
||||||
if message == nil {
|
if message == nil {
|
||||||
|
slog.Info("chat-type-middleware: update has no message. skipping.")
|
||||||
|
|
||||||
next(bot, update)
|
next(bot, update)
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.Info("chat-type-middleware: counting message chat type in stats", "type", message.Chat.Type)
|
||||||
|
|
||||||
switch message.Chat.Type {
|
switch message.Chat.Type {
|
||||||
case telego.ChatTypeGroup, telego.ChatTypeSupergroup:
|
case telego.ChatTypeGroup, telego.ChatTypeSupergroup:
|
||||||
b.stats.GroupRequest()
|
b.stats.GroupRequest()
|
||||||
|
|
Loading…
Reference in a new issue