This commit is contained in:
Pavel_Duron 2022-11-07 19:43:54 +10:00
parent 7ebca8c370
commit 0b5305c02a
2 changed files with 7 additions and 5 deletions

4
bot.py
View File

@ -46,8 +46,10 @@ async def dick(message: types.Message):
@dp.message_handler(commands=["id"]) @dp.message_handler(commands=["id"])
async def ident(message: types.Message): async def ident(message: types.Message):
id = message.from_user.id
fullname = message.from_user.fullname
#await sql.add_user() #await sql.add_user()
await bot.send_message(message.chat.id, f'{message.from_user.id}') await bot.send_message(message.chat.id, f'{id} {fullname}')
#await sql.db.close() #await sql.db.close()

4
sql.py
View File

@ -1,4 +1,5 @@
import sqlite3 as sq import sqlite3 as sq
import aiogram
async def db_start(): #подключение к бд async def db_start(): #подключение к бд
global db, cur global db, cur
@ -10,8 +11,7 @@ async def db_start(): #подключение к бд
db.commit() db.commit()
async def add_user(id): async def add_user(id):
cur.execute('''INSERT INTO users (users_id) VALUES (?)''',(id)) cur.execute('''INSERT INTO users (users_id, user_name) VALUES (?)''',[id, fullname])
id = message.from_user.id
db.commit() db.commit()