2021-12-03 12:19:55 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-01-28 01:00:40 +03:00
|
|
|
"kickerbot/captchagen"
|
2021-12-06 11:46:11 +03:00
|
|
|
"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"
|
2021-12-06 11:46:11 +03:00
|
|
|
"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() {
|
2021-12-06 11:46:11 +03:00
|
|
|
err := godotenv.Load()
|
2022-01-28 16:52:26 +03:00
|
|
|
captchagen.Init()
|
2021-12-06 11:46:11 +03:00
|
|
|
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 {
|
2021-12-06 11:46:11 +03:00
|
|
|
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) })
|
2023-09-13 22:33:53 +03:00
|
|
|
scheduler.Every(2).Minutes().Do(func() { kicker.TaskRemoveOldMutes(&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
|
|
|
}
|