how to implement a timer in a vk bot

I need to implement a temporary ban. I work with MySQL. Code execution occurs after a new event from LongPoll

import vk_api
import pymysql.cursors
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType

vk = vk_api.VkApi(token=token)
group = '12345678'
wait = 25
longpoll = VkBotLongPoll(vk, group, wait)

for event in longpoll.listen():
    #Вот здесь надо что то придумать
Author: Roman, 2020-01-10

1 answers

Create a table with the fields | id | time_end |

When someone gets a temporary ban, for example for an hour, then add the ID of this user to the database along with the end time of the ban in unixtime.

If the bot runs on linux, you can use the crontab utility to check every minute. Creating a script that pulls all banned users? go through them and check if the current time is longer than in the database, then remove the user from the database. banned. Put this script to run in cron every minute.

If on windows, then google other task schedulers

 0
Author: Kirill Minovsky, 2020-01-16 19:39:07