Reworked tasks
This commit is contained in:
parent
6be72fb3c6
commit
f5b7253fa6
|
@ -94,16 +94,16 @@ var HandlersV1 = []Handler{
|
|||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Endpoint: "/gen",
|
||||
Handler: func(c tb.Context) error {
|
||||
captcha := captchagen.GenCaptcha()
|
||||
reader := captcha.ToReader()
|
||||
caption := fmt.Sprintf("Правильный ответ: %d", captcha.CorrectAnswer)
|
||||
c.Reply(&tb.Photo{File: tb.FromReader(reader), Caption: caption})
|
||||
return nil
|
||||
},
|
||||
},
|
||||
// {
|
||||
// Endpoint: "/gen",
|
||||
// Handler: func(c tb.Context) error {
|
||||
// captcha := captchagen.GenCaptcha()
|
||||
// reader := captcha.ToReader()
|
||||
// caption := fmt.Sprintf("Правильный ответ: %d", captcha.CorrectAnswer)
|
||||
// c.Reply(&tb.Photo{File: tb.FromReader(reader), Caption: caption})
|
||||
// return nil
|
||||
// },
|
||||
// },
|
||||
{
|
||||
Endpoint: tb.OnAddedToGroup,
|
||||
Handler: func(c tb.Context) error {
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
func TaskKickOldUsers(b tb.Bot) {
|
||||
d := db.GetDatabase()
|
||||
db.Log("STARTING KICKING TASK", db.EmptyStruct{})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
now := time.Now().Unix()
|
||||
|
@ -29,6 +30,6 @@ func TaskKickOldUsers(b tb.Bot) {
|
|||
tbUser := tb.User{ID: user.Id}
|
||||
member := tb.ChatMember{User: &tbUser}
|
||||
b.Ban(&chat, &member)
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
d.RemoveUser(ctx, user)
|
||||
}
|
||||
}
|
||||
|
|
3
main.go
3
main.go
|
@ -30,9 +30,8 @@ func main() {
|
|||
Bot := kicker.Kicker{Token: token}
|
||||
Bot.Init()
|
||||
Bot.AddHandlers(kicker.HandlersV1)
|
||||
Bot.Bot.Start()
|
||||
|
||||
scheduler := gocron.NewScheduler(time.UTC)
|
||||
scheduler.Every(1).Minutes().Do(func() { kicker.TaskKickOldUsers(*Bot.Bot) })
|
||||
scheduler.StartAsync()
|
||||
Bot.Bot.Start()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue