KickerBot/main.go

44 lines
957 B
Go
Raw 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/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
2023-02-14 00:50:21 +03:00
"git.nefrace.ru/nefrace/tongo"
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
)
2023-02-14 00:50:21 +03:00
var client *tongo.Database
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")
}
2023-02-14 00:50:21 +03:00
client, err = tongo.NewConnection(os.Getenv("MONGO_URI"), "godotkicker")
// _, dberr := db.Init(os.Getenv("MONGO_URI"))
if err != nil {
log.Fatal(err)
}
2023-02-14 00:50:21 +03:00
kicker.Client = client
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) })
2023-02-14 00:56:18 +03:00
scheduler.Every(30).Seconds().Do(func() { kicker.TaskNotifyUsers(&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
}