import sqlite3
from aiogram import Bot, Dispatcher, executor, types
import re
from asyncio import sleep
API_TOKEN = '...'
bot = Bot(token=API_TOKEN, parse_mode=types.ParseMode.HTML)
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)
conn = sqlite3.connect('c:/users/sousa/bot/orders.db')
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS users(
userid INTEGER,
fname TEXT,
lname TEXT,
balance INTEGER DEFAULT (5000));
""")
conn.commit()
@dp.message_handler(regexp=r"(^Куб) ?(\d+)? ?(\d+)?")
async def process_start_command(message: types.Message):
command_parse = re.compile(r"(^Куб) ?(\d+)? ?(\d+)?")
parsed = command_parse.match(message.text)
dice_value = parsed.group(2)
summ = parsed.group(3)
name1 = message.from_user.get_mention(as_html=True)
if not dice_value:
await message.answer(f"<b>{name1}</b> введите сообщение в формате: \n<b>Куб (число от 1 до 6)</b>", parse_mode='html')
else:
dice_value = int(dice_value)
bot_data = await bot.send_dice (message.chat.id)
bot_data = bot_data['dice']['value']
await sleep(5)
if bot_data > dice_value:
await message.answer( f'{name1} ты <b>проиграл(а)</b>', parse_mode='html')
cur.execute("""UPDATE balance FROM users WHERE userid = ?
SET balance = balance - ?;
"""), (message.from_user.id, summ,)
elif bot_data < dice_value:
await message.answer( f'{name1} ты <b>проиграл(а)</b>', parse_mode='html')
cur.execute("""UPDATE balance FROM users WHERE userid = ?
SET balance = balance - ?;
"""), (message.from_user.id, summ,)
else:
await message.answer( f'{name1} ты <b>победил(а)</b>', parse_mode='html')
cur.execute("""UPDATE balance FROM users WHERE userid = ?
SET balance = balance + ?;
"""), (message.from_user.id, summ,)
Выдает ошибку:
sqlite3.OperationalError: near "FROM": syntax error