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()
}