mirror of
https://github.com/watn3y/steamsalty.git
synced 2025-04-20 00:11:23 +02:00
- Fixed SLEEPTIME not working (always 0) - Refined logging - Added metadata to /info command - Bot now automatically sets own commands for autocompletion
38 lines
902 B
Go
38 lines
902 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"watn3y/steamsalty/botIO"
|
|
"watn3y/steamsalty/commands"
|
|
"watn3y/steamsalty/steam"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func bot() {
|
|
updates, bot := botIO.Authenticate()
|
|
|
|
go commands.SetBotCommands(bot)
|
|
|
|
go steam.StartWatchers(bot)
|
|
|
|
for update := range updates {
|
|
log.Debug().Interface("update", update).Msg("Received update")
|
|
|
|
if update.Message == nil || update.Message.Text == "" {
|
|
log.Debug().Int("UpdateID", update.UpdateID).Msg("Unable to parse update")
|
|
continue
|
|
}
|
|
if update.Message.Time().UTC().Unix() < time.Now().UTC().Unix() {
|
|
log.Debug().Int("UpdateID", update.UpdateID).Msg("Skipping old update")
|
|
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)
|
|
}
|
|
}
|
|
}
|