tuple index out of range

Task exception was never retrieved
future: <Task finished name='Task-7' coro=<Dispatcher._process_polling_updates() done, defined at /data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py:407> exception=IndexError('tuple index out of range')>
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
    for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
    return await asyncio.gather(*tasks)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
    return await self.message_handlers.notify(update.message)
  File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "<string>", line 29, in b_key
IndexError: tuple index out of range
from aiogram import executor, Dispatcher, Bot, types
import sqlite3

TOKEN = 'токен'

bot = Bot(token=TOKEN)
dp = Dispatcher(bot)

con = sqlite3.connect('wtf.db')
cur = con.cursor()

cur.execute("CREATE TABLE IF NOT EXISTS peolpe (user_id INT, money BIGINT, status TEXT)")

@dp.message_handler(commands=('start'))
async def reg(message: types.Message):
    cur.execute(f"SELECT user_id FROM peolpe WHERE user_id ={message.from_user.id}")
    if cur.fetchone() is None:
        cur.execute("INSERT INTO peolpe VALUES (?, ?, 'human')", (message.from_user.id, 0, 'human'))
        con.commit()
        await message.reply('suessiful')

@dp.message_handler(text=('b'))
async def b_key(message: types.Message):
    for i in cur.execute(f"SELECT money FROM peolpe WHERE user_id ={message.from_user.id}"):
        
        balance = i[0]
        
        if balance == 0:
             balance = i[+1]
             await message.reply(f'Вы получили бонус!\n {balance}')
        else: await message.reply('suessiful')
        
    await bot.send_message(message.from_user.id, text=f'Привет {message.from_user.first_name}\nТвой баланс: {balance}')
    
@dp.message_handler(text=('bon'))
async def bon_key(message: types.Message):
    if cur.fetchone() is None:
        cur.execute("INSERT INTO peolpe VALUES (?, ?, ?)",(message.from_user.id, 0, 'human'))
        
        con.commit()
        await bot.send_message(message.from_user.id, text='Вы получили бонус!')
    else: message.reply('Вы уже получали бонус')

@dp.message_handler(text=('s'))
async def s_key(message: types.Message):
    for i in cur.execute(f"SELECT status FROM peolpe WHERE user_id ={message.from_user.id}"):
        
        status = i 
    
    await bot.send_message(message.from_user.id, text=f'Твой статус:\n{status}')
        
if __name__ == '__main__':
    executor.start_polling(dp)

Ответы (0 шт):