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