From 9aca8ad10ec90e8736eae9ce46227cabc441e471 Mon Sep 17 00:00:00 2001 From: dmitrium12 Date: Sat, 22 Apr 2023 13:34:23 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=83=20=D1=81=20api=20yandex=20?= =?UTF-8?q?lyceum=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=B7=20=D0=BA=D0=BE=D1=81=D1=82=D1=8B=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bot.py | 32 ++---- db.sql | Bin 65536 -> 65536 bytes functions/openai_answer.py | 2 +- functions/yandex.py | 51 ++++++++++ test.py | 198 +++++++++++++++++++++++++++++++++++++ 5 files changed, 257 insertions(+), 26 deletions(-) create mode 100644 functions/yandex.py diff --git a/Bot.py b/Bot.py index b63a772..cba61cc 100755 --- a/Bot.py +++ b/Bot.py @@ -1,14 +1,8 @@ from aiogram.utils import executor from loguru import logger from aiogram import Bot, Dispatcher, types -from functions import get_audio_messages_func, create_statistic, openai_answer +from functions import get_audio_messages_func, openai_answer, yandex import json -from selenium import webdriver -from selenium.webdriver.chrome.service import Service -from selenium.webdriver.common.by import By -from webdriver_manager.chrome import ChromeDriverManager -import requests -import time bot = Bot(token="5941118321:AAG0g0keLrlnuH_9U9X6ehpFFAdOX38qeXI") # создаю объект бота dp = Dispatcher(bot) # создаю объект слушателя @@ -29,24 +23,12 @@ async def start(message: types.Message): @dp.message_handler(commands=['statistic']) async def statistic(message: types.Message): - login = "Dmitrium12" - password = "" - options = webdriver.ChromeOptions() - options.add_argument("--headless") - driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) - driver.get('https://passport.yandex.ru/auth/') - time.sleep(1) - driver.find_element(By.CLASS_NAME, "Button2").click() - time.sleep(1) - driver.find_element(By.XPATH, '//*[@id="passp-field-login"]').send_keys(login) - driver.find_element(By.XPATH, '//*[@id="passp:sign-in"]').click() - time.sleep(1) - driver.find_element(By.XPATH, '//*[@id="passp-field-passwd"]').send_keys(password) - driver.find_element(By.XPATH, '//*[@id="passp:sign-in"]').click() - time.sleep(5) - cookies = {"Session_id": [i["value"] for i in driver.get_cookies() if i["name"] == "Session_id"][0]} - response = requests.get("https://lyceum.yandex.ru/api/notifications?isRead=false&limit=20", cookies=cookies) - await message.reply(f'У вас {response.json()["unreadCount"]} уведомлений. Прочитайте хоть') + await yandex.statistic(message) + + +@dp.message_handler(commands=['create_yandex']) +async def create_yandex(message: types.Message): + await yandex.create_yandex(message) @dp.message_handler(commands=['r']) diff --git a/db.sql b/db.sql index 121e10e0123ed9a926c6432251b234b71bed280a..796d2299742c9f2880d83206e708625055e8b711 100644 GIT binary patch delta 694 zcmZo@U}HgS8&$@zQ|q7W0}jUhCrwirx?A1Y%6p?Nm%;$mlJW)orCe1zAOk%LuSTNI{L z5USJ=LUS7nPLAi7+3d!@PeFinsHNB&3rm-r9yZ{}aVSx{jzKM&9-Nk)ij=FOY! zeI0nXfC0wH-^>6+JezqM()sHr$TL=}BYdJ>!_rvIXl!L@W?^J#Vq$4&qGzgSpoid^ z8X8y`I(x=Drdt^$=^5%7SsB)tn^_nb8JQRv096|4A#1Jyatw^jEX>VK^-K+oEi8f3 zZl!r8md2I&uA$lfvUgkLlY5Cr+MvlJBykPg$GVs>|eUQRmKb3){NnYh=pa8^; zjSS4J3_u5hM3Akal^bOtjzn=IBnW>o@c-JZ*zkd0fR&k%k(n7H`kjIQJ5cm3KPLw> N3nR#t%!>{<007o8v_Sv> delta 206 zcmZo@U}rJ3V&GfCvw(jR?@7K) z?!Wx8+)?}*T)X(sZWdIq;M%;4i=BC50LSK&yatShM&k1Fj7{k!Y#eMrgBTbZE!o+{ zt*sfGI7