bloaterbot/bot.go
2024-06-03 22:40:17 +02:00

46 lines
1 KiB
Go

package main
import (
"time"
"github.com/rs/zerolog/log"
"watn3y.de/bloaterbot/botIO"
"watn3y.de/bloaterbot/commands"
"watn3y.de/bloaterbot/commands/notify"
"watn3y.de/bloaterbot/inline/nenefoot"
"watn3y.de/bloaterbot/text"
)
func bot() {
updates, bot := botIO.Authenticate()
go notify.NotifyHandler(bot)
for update := range updates {
log.Trace().Interface("update", update).Msg("Received update")
if update.InlineQuery != nil && update.Message == nil {
nenefoot.Nenefoot(update, bot)
continue
}
if update.Message != nil && update.Message.Text != "" {
if update.Message.Time().UTC().Unix() < time.Now().UTC().Unix() {
continue
}
log.Info().Int64("ChatID", update.Message.Chat.ID).Int64("UserID", update.Message.From.ID).Str("Text", update.Message.Text).Msg("Recieved Message")
if update.Message.IsCommand() {
commands.Commands(update, bot)
} else {
text.Matcher(update, bot)
continue
}
}
log.Trace().Interface("update", update).Msg("Unable to parse update")
}
}