From 5e9b34ef7a1ad777c138d9668f6479e34ae715a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CB=B9=E1=B4=A7=C9=B4=CF=83=C9=B4=CA=8F=E1=B4=8D=CF=83?= =?UTF-8?q?=E1=B4=9Cs=20=EA=AD=99=CB=BC?= Date: Mon, 30 Jan 2023 20:02:24 +0530 Subject: [PATCH] Removed pyro v1 support --- StringGenBot/generate.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/StringGenBot/generate.py b/StringGenBot/generate.py index 3aa3bc8..f715d2b 100644 --- a/StringGenBot/generate.py +++ b/StringGenBot/generate.py @@ -1,7 +1,6 @@ from pyrogram.types import Message from telethon import TelegramClient from pyrogram import Client, filters -from pyrogram1 import Client as Client1 from asyncio.exceptions import TimeoutError from telethon.sessions import StringSession from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton @@ -13,14 +12,6 @@ SessionPasswordNeeded, PasswordHashInvalid ) -from pyrogram1.errors import ( - ApiIdInvalid as ApiIdInvalid1, - PhoneNumberInvalid as PhoneNumberInvalid1, - PhoneCodeInvalid as PhoneCodeInvalid1, - PhoneCodeExpired as PhoneCodeExpired1, - SessionPasswordNeeded as SessionPasswordNeeded1, - PasswordHashInvalid as PasswordHashInvalid1 -) from telethon.errors import ( ApiIdInvalidError, PhoneNumberInvalidError, @@ -37,10 +28,7 @@ ask_ques = "**» ᴩʟᴇᴀsᴇ ᴄʜᴏᴏsᴇ ᴛʜᴇ ᴩʏᴛʜᴏɴ ʟɪʙʀᴀʀʏ ғᴏʀ ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ɢᴇɴᴇʀᴀᴛᴇ sᴛʀɪɴɢ :**" buttons_ques = [ [ - InlineKeyboardButton("ᴩʏʀᴏɢʀᴀᴍ", callback_data="pyrogram1"), - InlineKeyboardButton("ᴩʏʀᴏɢʀᴀᴍ ᴠ2", callback_data="pyrogram"), - ], - [ + InlineKeyboardButton("ᴩʏʀᴏɢʀᴀᴍ", callback_data="pyrogram"), InlineKeyboardButton("ᴛᴇʟᴇᴛʜᴏɴ", callback_data="telethon"), ], [ @@ -63,13 +51,11 @@ async def main(_, msg): await msg.reply(ask_ques, reply_markup=InlineKeyboardMarkup(buttons_ques)) -async def generate_session(bot: Client, msg: Message, telethon=False, old_pyro: bool = False, is_bot: bool = False): +async def generate_session(bot: Client, msg: Message, telethon=False, is_bot: bool = False): if telethon: ty = "ᴛᴇʟᴇᴛʜᴏɴ" else: ty = "ᴩʏʀᴏɢʀᴀᴍ" - if not old_pyro: - ty += " ᴠ2" if is_bot: ty += " ʙᴏᴛ" await msg.reply(f"» ᴛʀʏɪɴɢ ᴛᴏ sᴛᴀʀᴛ **{ty}** sᴇssɪᴏɴ ɢᴇɴᴇʀᴀᴛᴏʀ...") @@ -108,8 +94,6 @@ async def generate_session(bot: Client, msg: Message, telethon=False, old_pyro: client = TelegramClient(StringSession(), api_id, api_hash) elif is_bot: client = Client(name="bot", api_id=api_id, api_hash=api_hash, bot_token=phone_number, in_memory=True) - elif old_pyro: - client = Client1(":memory:", api_id=api_id, api_hash=api_hash) else: client = Client(name="user", api_id=api_id, api_hash=api_hash, in_memory=True) await client.connect() @@ -120,10 +104,10 @@ async def generate_session(bot: Client, msg: Message, telethon=False, old_pyro: code = await client.send_code_request(phone_number) else: code = await client.send_code(phone_number) - except (ApiIdInvalid, ApiIdInvalidError, ApiIdInvalid1): + except (ApiIdInvalid, ApiIdInvalidError): await msg.reply("» ʏᴏᴜʀ **ᴀᴩɪ_ɪᴅ** ᴀɴᴅ **ᴀᴩɪ_ʜᴀsʜ** ᴄᴏᴍʙɪɴᴀᴛɪᴏɴ ᴅᴏᴇsɴ'ᴛ ᴍᴀᴛᴄʜ ᴡɪᴛʜ ᴛᴇʟᴇɢʀᴀᴍ ᴀᴩᴩs sʏsᴛᴇᴍ. \n\nᴩʟᴇᴀsᴇ sᴛᴀʀᴛ ɢᴇɴᴇʀᴀᴛɪɴɢ ʏᴏᴜʀ sᴇssɪᴏɴ ᴀɢᴀɪɴ.", reply_markup=InlineKeyboardMarkup(gen_button)) return - except (PhoneNumberInvalid, PhoneNumberInvalidError, PhoneNumberInvalid1): + except (PhoneNumberInvalid, PhoneNumberInvalidError): await msg.reply("» ᴛʜᴇ **ᴩʜᴏɴᴇ_ɴᴜᴍʙᴇʀ** ʏᴏᴜ'ᴠᴇ sᴇɴᴛ ᴅᴏᴇsɴ'ᴛ ʙᴇʟᴏɴɢ ᴛᴏ ᴀɴʏ ᴛᴇʟᴇɢʀᴀᴍ ᴀᴄᴄᴏᴜɴᴛ.\n\nᴩʟᴇᴀsᴇ sᴛᴀʀᴛ ɢᴇɴᴇʀᴀᴛɪɴɢ ʏᴏᴜʀ sᴇssɪᴏɴ ᴀɢᴀɪɴ.", reply_markup=InlineKeyboardMarkup(gen_button)) return try: @@ -142,13 +126,13 @@ async def generate_session(bot: Client, msg: Message, telethon=False, old_pyro: await client.sign_in(phone_number, phone_code, password=None) else: await client.sign_in(phone_number, code.phone_code_hash, phone_code) - except (PhoneCodeInvalid, PhoneCodeInvalidError, PhoneCodeInvalid1): + except (PhoneCodeInvalid, PhoneCodeInvalidError): await msg.reply("» ᴛʜᴇ ᴏᴛᴩ ʏᴏᴜ'ᴠᴇ sᴇɴᴛ ɪs **ᴡʀᴏɴɢ.**\n\nᴩʟᴇᴀsᴇ sᴛᴀʀᴛ ɢᴇɴᴇʀᴀᴛɪɴɢ ʏᴏᴜʀ sᴇssɪᴏɴ ᴀɢᴀɪɴ.", reply_markup=InlineKeyboardMarkup(gen_button)) return - except (PhoneCodeExpired, PhoneCodeExpiredError, PhoneCodeExpired1): + except (PhoneCodeExpired, PhoneCodeExpiredError): await msg.reply("» ᴛʜᴇ ᴏᴛᴩ ʏᴏᴜ'ᴠᴇ sᴇɴᴛ ɪs **ᴇxᴩɪʀᴇᴅ.**\n\nᴩʟᴇᴀsᴇ sᴛᴀʀᴛ ɢᴇɴᴇʀᴀᴛɪɴɢ ʏᴏᴜʀ sᴇssɪᴏɴ ᴀɢᴀɪɴ.", reply_markup=InlineKeyboardMarkup(gen_button)) return - except (SessionPasswordNeeded, SessionPasswordNeededError, SessionPasswordNeeded1): + except (SessionPasswordNeeded, SessionPasswordNeededError): try: two_step_msg = await bot.ask(user_id, "» ᴩʟᴇᴀsᴇ ᴇɴᴛᴇʀ ʏᴏᴜʀ **ᴛᴡᴏ sᴛᴇᴩ ᴠᴇʀɪғɪᴄᴀᴛɪᴏɴ** ᴩᴀssᴡᴏʀᴅ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ.", filters=filters.text, timeout=300) except TimeoutError: @@ -162,7 +146,7 @@ async def generate_session(bot: Client, msg: Message, telethon=False, old_pyro: await client.check_password(password=password) if await cancelled(api_id_msg): return - except (PasswordHashInvalid, PasswordHashInvalidError, PasswordHashInvalid1): + except (PasswordHashInvalid, PasswordHashInvalidError): await two_step_msg.reply("» ᴛʜᴇ ᴩᴀssᴡᴏʀᴅ ʏᴏᴜ'ᴠᴇ sᴇɴᴛ ɪs ᴡʀᴏɴɢ.\n\nᴩʟᴇᴀsᴇ sᴛᴀʀᴛ ɢᴇɴᴇʀᴀᴛɪɴɢ ʏᴏᴜʀ sᴇssɪᴏɴ ᴀɢᴀɪɴ.", quote=True, reply_markup=InlineKeyboardMarkup(gen_button)) return else: