pgbot-go/main.go
2025-02-09 19:34:10 +02:00

44 lines
701 B
Go

package main
import (
"log"
"time"
"mechanus.net/pgbot/config"
"mechanus.net/pgbot/matcher"
"mechanus.net/pgbot/responder"
"gopkg.in/telebot.v4"
)
const (
confFile string = "config.yml"
cronFile string = "cron.yml"
matchFile string = "tokens.yml"
)
type configSpec struct {
TGToken string `yaml:"tg_bot_token"`
}
func main() {
var conf configSpec
config.Parse(confFile, &conf)
pref := telebot.Settings{
Token: conf.TGToken,
Poller: &telebot.LongPoller{Timeout: 10 * time.Second},
}
tokenMatcher := matcher.InitMatcher(matchFile)
bot, err := telebot.NewBot(pref)
if err != nil {
log.Fatal(err)
return
}
responder.InitResponder(bot, tokenMatcher)
bot.Start()
}