Answer the question
In order to leave comments, you need to log in
How to fix list index out of range error?
@bot.message_handler(content_types=['text'])
def handle_text(message):
with sqlite3.connect('ref.db') as conn:
cur = conn.cursor()
cur.execute("SELECT `ban` FROM `users` WHERE id_user =?", (message.chat.id,))
rows = cur.fetchall()
if 'True' in rows[0]:
bot.send_message(message.chat.id, 'Тебя забанили')
Answer the question
In order to leave comments, you need to log in
Add a check that the selection from the database has a result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question