@dp.message_handler(commands=['top'])
async def top(message: types.Message):
conn = sqlite3.connect('db.db')
with conn:
cur = conn.cursor()
cur.execute("SELECT * FROM users ORDER BY money DESC LIMIT 5")
data = cur.fetchall()
for i, v in enumerate(data, 1):
print(i)
text = '\n'.join((f'{i}. {row[1]}: {row[5]} - монеты' for row in data))
await message.reply(text)
Traceback (most recent call last):
File "C:\Users\Макс\Desktop\telebot\bot.py", line 602, in <module>
async def send_random_value(call: types.CallbackQuery):
File "D:\Питон\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 854, in decorator
self.register_callback_query_handler(callback, *custom_filters, state=state, run_task=run_task, **kwargs)
File "D:\Питон\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 830, in register_callback_query_handler
filters_set = self.filters_factory.resolve(self.callback_query_handlers,
File "D:\Питон\lib\site-packages\aiogram\dispatcher\filters\factory.py", line 52, in resolve
filters_set.extend(self._resolve_registered(event_handler,
File "D:\Питон\lib\site-packages\aiogram\dispatcher\filters\factory.py", line 73, in _resolve_registered
raise NameError("Invalid filter name(s): '" + "', ".join(full_config.keys()) + "'")
NameError: Invalid filter name(s): 'func'
@dp.message_handler(commands=['top'])
async def top(message: types.Message):
conn = sqlite3.connect('db.db')
cur = conn.cursor()
cur.execute("SELECT * FROM users ORDER BY money DESC LIMIT 5")
data = cur.fetchall()
text = (f'{row[1]}: {row[5]} - монет' for row in data)
for i, v in enumerate(text, 1):
text1 = ''.join((f'{i}. {v}'))
await message.reply(text1)
@dp.message_handler(commands=['top'])
async def top(message: types.Message):
conn = sqlite3.connect('db.db')
with conn:
cur = conn.cursor()
cur.execute("SELECT * FROM users ORDER BY money DESC LIMIT 5")
while True:
row = cur.fetchone()
if row == None:
break
await message.reply(f'{row[1]}: {row[5]} - монет')
@dp.message_handler(commands=['go'])
async def go(message: types.Message):
conn = sqlite3.connect('db.db')
cur = conn.cursor()
user_id = message.from_user.id
date = message.date
result = cur.execute("SELECT * FROM users WHERE user_id = ?", (user_id, )).fetchone()
datem = result[11]
if datem == 0:
number = message.date
cur.execute("UPDATE users SET datem = ? WHERE user_id = ?", (number, user_id))
conn.commit()
await message.reply('Готово')
else:
await message.reply('Осталось ... времени')
@dp.message_handler(commands=['number'])
async def number(message: types.Message):
number = message.get_args()
number1 = int(number)*1000
if int(number) < 0:
await message.reply("Нельзя вводить отрицательное число")
else:
await message.reply(f"Твое число {number1}")
@dp.message_handler(commands=['dice'])
async def dice_handler(message: types.Message):
user_data = await message.answer_dice(emoji="")
conn = sqlite3.connect('db.db')
cur = conn.cursor()
user_id = message.from_user.id
user_data = user_data['dice']['value']
number = user_data*10
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await sleep(4)
await message.reply(f"Число {user_data}")
@dp.message_handler(commands=['dice'])
async def dice_handler(message: types.Message):
user_data = await message.answer_dice(emoji="")
user_data = user_data['dice']['value']
conn = sqlite3.connect('db.db')
cur = conn.cursor()
user_id = message.from_user.id
result = cur.execute("SELECT * FROM users WHERE user_id = ?", (user_id, )).fetchone()
nomer = result[5]
if user_data == 1:
await sleep(4)
number = 1
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await message.reply("Число 1")
elif user_data == 2:
await sleep(4)
number = 2
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await message.reply("Число 2")
elif user_data == 3:
await sleep(4)
number = 3
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await message.reply("Число 3")
elif user_data == 4:
await sleep(4)
number = 4
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await message.reply("Число 4")
elif user_data == 5:
await sleep(4)
number = 5
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await message.reply("Число 5")
elif user_data == 6:
await sleep(4)
number = 6
cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (number, user_id))
await message.reply("Число 6")
@dp.message_handler(commands=['dice'])
async def dice_handler(message: types.Message):
user_data = await message.answer_dice(emoji="")
user_data = user_data['dice']['value']
conn = sqlite3.connect('db.db')
cur = conn.cursor()
user_id = message.from_user.id
result = cur.execute("SELECT * FROM users WHERE user_id = ?", (user_id, )).fetchone()
nomer = result[5]
if user_data == 1:
await sleep(4)
await message.reply("Число 1")
recordset.Update nomer, nomer + 1
record.Fields.Update
elif user_data == 2:
await sleep(4)
await message.reply("Число 2")
recordset.Update nomer, nomer + 1
record.Fields.Update
elif user_data == 3:
await sleep(4)
await message.reply("Число 3")
recordset.Update nomer, nomer + 1
record.Fields.Update
elif user_data == 4:
await sleep(4)
await message.reply("Число 4")
recordset.Update nomer, nomer + 1
record.Fields.Update
elif user_data == 5:
await sleep(4)
await message.reply("Число 5")
recordset.Update nomer, nomer + 1
record.Fields.Update
elif user_data == 6:
await sleep(4)
await message.reply("Число 6")
recordset.Update nomer, nomer + 1
record.Fields.Update