KickerBot/main.go

39 lines
736 B
Go
Raw Permalink Normal View History

2021-12-03 12:19:55 +03:00
package main
import (
2022-01-28 01:00:40 +03:00
"kickerbot/captchagen"
"kickerbot/db"
"kickerbot/kicker"
2021-12-03 12:19:55 +03:00
"log"
"os"
2022-02-04 12:39:57 +03:00
"time"
2021-12-03 12:19:55 +03:00
2022-11-09 00:45:08 +03:00
"github.com/NicoNex/echotron/v3"
2022-02-04 12:39:57 +03:00
"github.com/go-co-op/gocron"
"github.com/joho/godotenv"
2021-12-03 12:19:55 +03:00
)
func main() {
err := godotenv.Load()
2022-01-28 16:52:26 +03:00
captchagen.Init()
if err != nil {
log.Print("Error loading .env file")
}
2021-12-03 12:19:55 +03:00
token, exists := os.LookupEnv("TOKEN")
if !exists {
log.Fatal("no token specified")
}
2021-12-07 01:18:44 +03:00
_, dberr := db.Init(os.Getenv("MONGO_URI"))
if dberr != nil {
log.Fatal(err)
}
2021-12-03 12:19:55 +03:00
2021-12-03 14:30:10 +03:00
Bot := kicker.Kicker{Token: token}
2021-12-03 12:19:55 +03:00
Bot.Init()
2022-02-04 12:39:57 +03:00
scheduler := gocron.NewScheduler(time.UTC)
2022-11-09 00:45:08 +03:00
tasker := echotron.NewAPI(token)
scheduler.Every(30).Seconds().Do(func() { kicker.TaskKickOldUsers(&tasker) })
2022-02-04 12:39:57 +03:00
scheduler.StartAsync()
2022-11-09 00:45:08 +03:00
Bot.Start()
2021-12-03 12:19:55 +03:00
}