import logging
from aiogram import Bot, Dispatcher, executor, types
from aiogram.types import ContentType
from aiogram.types import CallbackQuery
import sqlite3
import keyboard as kb
db = sqlite3.connect('a.db', check_same_thread=False)
sql = db.cursor()
# Create table
sql.execute('''CREATE TABLE IF NOT EXISTS name(
id TEXT,
call_data TEXT
) ''')
db.commit()
i = [('AgACAgIAAxkBAAMoX52AILubJTBkHIWQDBZNRbu9PRoAAnOuMRslGPBIqyRYTDLP-zP8r2yWLgADAQADAgADeQAD7lMDAAEbBA', 'biology1'), # 1
('AgACAgIAAxkBAAMTX51vtvhTqKaKrMoQe0r7l93jKdgAAi-uMRslGPBIzdcC4cmshh64HMqXLgADAQADAgADeQAD9kwCAAEbBA', 'biology2'), # 2
('AgACAgIAAxkBAAMUX51v5aoa9qRAx8o8Ub1devWWlFsAAjCuMRslGPBIzCn_lCvoFQABdfbVli4AAwEAAwIAA3kAA-MWAwABGwQ', 'biology3'), # 3
('AgACAgIAAxkBAAMVX51wAfEiXLTsO1lb_JlD15nIbF8AAjGuMRslGPBIksT_5qzkdh9TvtGXLgADAQADAgADeQADA0kCAAEbBA', 'biology4',), # 4
('AgACAgIAAxkBAAMWX51wKPwPL6BtFk2d90-UfM2liQADM64xGyUY8Ejvts84eaMBI1UHbZcuAAMBAAMCAAN5AAPBhwIAARsE', 'biology5'),# 5
('AgACAgIAAxkBAAMXX51wRT5hl_i5izo1xkiJezgdELkAAjSuMRslGPBIZZ9G0nGii0VUidqWLgADAQADAgADeQADbhYDAAEbBA', 'biology6'), # 6
('AgACAgIAAxkBAAMYX51wZv_o26Ohj8ia7mfhGARFtTwAAjWuMRslGPBIIuQNlERX9q77QfCXLgADAQADAgADeQAD-F8CAAEbBA', 'biology7'), # 7
('AgACAgIAAxkBAAMZX51weLPHXSMNVEc1JJZmepYRCroAAjauMRslGPBI1lggOS2VoWYzThKVLgADAQADAgADeQADbPwFAAEbBA', 'biology8'),# 8
('AgACAgIAAxkBAAMaX51wrTasDFXGR_U3SG8X_uhIXZsAAjiuMRslGPBIII74ck-HyhldQfCXLgADAQADAgADeQADeF4CAAEbBA', 'biology9'),# 9
('AgACAgIAAxkBAAMbX51w1pVNOPuGQXXZdf1_KRkIs_oAAjmuMRslGPBIHNpb2rJgdCPicGaaLgADAQADAgADeQAD3jwAAhsE', 'biology10'),# 10
('AgACAgIAAxkBAAMcX51w9ZbT62kpsxxfbLF2V_cadmMAAjquMRslGPBICyax5fqh6QmIyNSXLgADAQADAgADeQAD2kUCAAEbBA', 'biology11'),# 11
('AgACAgIAAxkBAAMdX51yk_DOGnce-q8BMQ9p8QMisrsAAj2uMRslGPBIh5e5PZKTBFrsidqWLgADAQADAgADeQAD7BwDAAEbBA', 'biology12'),# 12
('AgACAgIAAxkBAAMfX51yuXJ3RiEpNcjw9jWYKmBiBRgAAj-uMRslGPBI1mkAAfyT81nOW_fVli4AAwEAAwIAA3kAA3oTAwABGwQ', 'biology13'), # 13
('AgACAgIAAxkBAAMeX51ypQUIyrj8dOnnoR1Bsi-7o18AAj6uMRslGPBI5BxfiHfa7bomy9SXLgADAQADAgADeQAESgIAARsE', 'biology14'),# 14
('AgACAgIAAxkBAAMgX51y3GZNrQOq8zvc3_EOVgjMYlMAAkCuMRslGPBI3viUpRuceGITYmOaLgADAQADAgADeQADbjwAAhsE', 'biology15'), # 15
('AgACAgIAAxkBAAMhX51y9Kn5RcheSLLZRkqqPUmqWrwAAkGuMRslGPBI_6RgySb6r0iwTRKVLgADAQADAgADeQADOQEGAAEbBA', 'biology16'), # 16
('AgACAgIAAxkBAAMiX51zBqSw6KE9149bZfWOT-l3uDsAAkKuMRslGPBIUd6qdzTMtwiJRAWXLgADAQADAgADeQAD5GYCAAEbBA', 'biology17'),# 17
('AgACAgIAAxkBAAMjX51zFtQQg0PX5Q34fZkM-HyCaiMAAkOuMRslGPBIcRFhXI7x6jG6FKKWLgADAQADAgADeQADVVQDAAEbBA', 'biology18'), # 18
('AgACAgIAAxkBAAMkX51zJHHtkFwyC2Ikd59BXKxib0kAAkSuMRslGPBIgAGrOO9maN5KZRaYLgADAQADAgADeQADpHYCAAEbBA', 'biology19'),# 19
('AgACAgIAAxkBAAMlX51zN1UpWOVa6GyJS1Fz-rDhm-AAAkWuMRslGPBI4s5xGhHJNIVH4haVLgADAQADAgADeQADhvwFAAEbBA', 'biology20'),# 20
('AgACAgIAAxkBAAMmX51zQ8zG3istpVZ7tiwswoeqSjQAAkauMRslGPBI5O2JGT8lYKZPcmiXLgADAQADAgADeQADroYCAAEbBA', 'biology21'), # 21
('AgACAgIAAxkBAAMnX51zU4-vxT3GFklSZaKkdr8S8jIAAkeuMRslGPBIjfZu55KrEViR5T6WLgADAQADAgADeQADTbwDAAEbBA', 'biology22') # 22
]
for ii in i:
sql.execute('SELECT id FROM name WHERE call_data = (?)', (ii[1],))
if sql.fetchone() is None:
sql.execute('INSERT INTO name VALUES (?, ?)', (ii[0], ii[1]))
db.commit()
else:
pass
logging.basicConfig(level=logging.INFO)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def send_welcome(message: types.Message):
await bot.send_message(message.chat.id, "Привет выбери какой предмет тебе нужен", reply_markup=kb.button_1)
@dp.message_handler(content_types=ContentType.PHOTO)
async def photo(message):
fileID = message.photo[-1].file_id
print(fileID)
@dp.callback_query_handler(lambda call: True)
async def keyboard(call: CallbackQuery):
if 'biology' in call.data:
sql.execute(f"SELECT id FROM name WHERE call_data = (?)", ('biology1',))
rows = sql.fetchall()
print(rows)
await bot.send_photo(call.message.chat.id, photo=rows[0],)
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)