2024-03-11 20:15:27 +00:00
|
|
|
package bot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mymmrac/telego"
|
|
|
|
"github.com/mymmrac/telego/telegohandler"
|
2024-03-12 19:10:34 +00:00
|
|
|
"log/slog"
|
2024-03-11 20:15:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (b *Bot) chatTypeStatsCounter(bot *telego.Bot, update telego.Update, next telegohandler.Handler) {
|
|
|
|
message := update.Message
|
|
|
|
|
|
|
|
if message == nil {
|
2024-03-12 19:10:34 +00:00
|
|
|
slog.Info("chat-type-middleware: update has no message. skipping.")
|
|
|
|
|
2024-03-11 20:15:27 +00:00
|
|
|
next(bot, update)
|
2024-03-12 19:10:34 +00:00
|
|
|
|
|
|
|
return
|
2024-03-11 20:15:27 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 19:10:34 +00:00
|
|
|
slog.Info("chat-type-middleware: counting message chat type in stats", "type", message.Chat.Type)
|
|
|
|
|
2024-03-11 20:15:27 +00:00
|
|
|
switch message.Chat.Type {
|
|
|
|
case telego.ChatTypeGroup, telego.ChatTypeSupergroup:
|
|
|
|
b.stats.GroupRequest()
|
|
|
|
case telego.ChatTypePrivate:
|
|
|
|
b.stats.PrivateRequest()
|
|
|
|
}
|
|
|
|
|
|
|
|
next(bot, update)
|
|
|
|
}
|