From 99533b80e6059899344d4edf8e7b14380d26bd95 Mon Sep 17 00:00:00 2001 From: Pavel_Duron Date: Mon, 7 Nov 2022 17:04:34 +1000 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D1=87=D0=B0=D0=BB=20=D0=B1=D0=B4,?= =?UTF-8?q?=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=BB=D0=B8=D1=88?= =?UTF-8?q?=D0=BD=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 10 ++++++++-- sql.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index e67ee15..295a260 100644 --- a/bot.py +++ b/bot.py @@ -5,9 +5,9 @@ from random import randint from aiogram import Bot, Dispatcher, executor, types from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton -#import sql +import sql -#sql.db_start() +sql.db_start() API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w' @@ -45,6 +45,12 @@ async def dick(message: types.Message): numb = (f"Рандомное число : {randint(-7,10)}") await bot.send_message(message.chat.id, (numb)) +@dp.message_handler(commands=["id"]) +async def id(message: types.Message): + await sql.db_start() + await bot.send_message(message.chat.id, f'ваш id {message.from_user.id}') + await sql.db.close() + #####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________ diff --git a/sql.py b/sql.py index f882117..07cf8ce 100644 --- a/sql.py +++ b/sql.py @@ -6,14 +6,19 @@ async def db_start(): #подключение к бд db = sq.connect('dickpick.db') cur = db.cursor() - cur.execute('CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT, dick_size INTEGER)') + cur.execute(''''CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, users_id INTEGER, user_name TEXT, dick_size INTEGER)''') db.commit() -async def add_user(): - cur.execute('INSERT INTO users (users_id, user_name) VALUES (?, ?,)'.format(message.from_user.id, message.from_user.fullname)) +async def add_user(id): + cur.execute('''INSERT INTO users (users_id) VALUES (?)''',(id)) + id = message.from_user.id db.commit() +db.commit() + + +