added task scheduler
This commit is contained in:
		| @ -11,7 +11,7 @@ import ( | ||||
| 	tb "gopkg.in/tucnak/telebot.v3" | ||||
| ) | ||||
|  | ||||
| func KickOldUsers(b tb.Bot) { | ||||
| func TaskKickOldUsers(b tb.Bot) { | ||||
| 	d := db.GetDatabase() | ||||
| 	ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) | ||||
| 	defer cancel() | ||||
|  | ||||
							
								
								
									
										6
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.go
									
									
									
									
									
								
							| @ -6,7 +6,9 @@ import ( | ||||
| 	"kickerbot/kicker" | ||||
| 	"log" | ||||
| 	"os" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/go-co-op/gocron" | ||||
| 	"github.com/joho/godotenv" | ||||
| ) | ||||
|  | ||||
| @ -29,4 +31,8 @@ func main() { | ||||
| 	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() | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user