31 lines
737 B
Go
31 lines
737 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
"watn3y/bloaterbot/botIO"
|
|
"watn3y/bloaterbot/commands"
|
|
"watn3y/bloaterbot/commands/notify"
|
|
"watn3y/bloaterbot/text"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func bot() {
|
|
updates, bot := botIO.Authenticate()
|
|
go notify.NotifyHandler(bot)
|
|
now := time.Now().UTC()
|
|
for update := range updates {
|
|
if update.Message == nil || update.Message.Time().UTC().Unix() < now.UTC().Unix() {
|
|
continue
|
|
}
|
|
|
|
log.Info().Int64("user", update.Message.From.ID).Int64("chat", update.Message.Chat.ID).Str("msg", update.Message.Text).Msg("Recieved update:")
|
|
log.Debug().Interface("update", update).Msg("")
|
|
|
|
if update.Message.IsCommand() {
|
|
commands.Commands(update, bot)
|
|
} else {
|
|
text.Matcher(update, bot)
|
|
}
|
|
|
|
}
|
|
}
|