Answer the question
In order to leave comments, you need to log in
How to implement this through telebot and datetime?
The person writes: send
Bot answers: ready
Otherwise: if an hour has not passed after the next request, the bot cannot write.
Preferably with code, because I'm a nerd at this
Answer the question
In order to leave comments, you need to log in
We need to work with the database. sqlite3 will do.
After the bot sends a message "done", you need to add a record about this (if the user is new to the bot, or update the record if he has already sent a request). Where table is the name of the table.
sql = ('INSERT INTO table (user_id, date) VALUES (?, ?)')
val = (str(message.chat.id), date) #date - Это ЧЧ:ММ в формате 24часовой системы. Не надо полную дату.
cursor.execute(sql, val)
db.commit()
#Или обновить
cursor.execute('UPDATE date = "' + date + '" FROM table WHERE user_id = "' + str(message.chat.id) + '"')
db.commit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question