mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-24 21:53:37 +00:00
🔖 Update to v1.2.19
This commit is contained in:
parent
e78deaec9e
commit
a273482e30
@ -13,9 +13,9 @@ from pagermaid.scheduler import scheduler
|
||||
import pyromod.listen
|
||||
from pyrogram import Client
|
||||
|
||||
from pyromod.listen.temp_fix import temp_fix
|
||||
from pyromod.listen.temp_fix import temp_fix, sent_code_parse, fix_authorize
|
||||
|
||||
pgm_version = "1.2.18"
|
||||
pgm_version = "1.2.19"
|
||||
CMD_LIST = {}
|
||||
module_dir = __path__[0]
|
||||
working_dir = getcwd()
|
||||
@ -69,6 +69,10 @@ bot = Client(
|
||||
# temp fix topics group
|
||||
setattr(pyrogram.types.Message, "old_parse", getattr(pyrogram.types.Message, "_parse"))
|
||||
setattr(pyrogram.types.Message, "_parse", temp_fix)
|
||||
# temp fix +888
|
||||
setattr(pyrogram.types.SentCode, "old_parse", getattr(pyrogram.types.SentCode, "_parse"))
|
||||
setattr(pyrogram.types.SentCode, "_parse", sent_code_parse)
|
||||
Client.authorize = fix_authorize
|
||||
bot.job = scheduler
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ from os import sep
|
||||
from importlib import import_module
|
||||
|
||||
from pyrogram import idle
|
||||
from pyrogram.errors import AuthKeyUnregistered
|
||||
|
||||
from pagermaid import bot, logs, working_dir
|
||||
from pagermaid.hook import Hook
|
||||
@ -16,7 +17,11 @@ path.insert(1, f"{working_dir}{sep}plugins")
|
||||
async def main():
|
||||
logs.info(lang('platform') + platform + lang('platform_load'))
|
||||
|
||||
try:
|
||||
await bot.start()
|
||||
except AuthKeyUnregistered:
|
||||
safe_remove("pagermaid.session")
|
||||
exit()
|
||||
|
||||
me = await bot.get_me()
|
||||
if me.is_bot:
|
||||
|
@ -51,7 +51,7 @@ class Config:
|
||||
LOG_ID = int(os.environ.get("PGM_LOG_ID", config["log_chatid"]))
|
||||
IPV6 = strtobool(os.environ.get("PGM_IPV6", config["ipv6"]))
|
||||
ALLOW_ANALYTIC = strtobool(os.environ.get("PGM_ALLOW_ANALYTIC", config["allow_analytic"]), True)
|
||||
SENTRY_API = "https://fbff8c554f6a44b989b490864679546e@o1342815.ingest.sentry.io/6617119"
|
||||
SENTRY_API = "https://2e13a517aeb542e7a307cba8996b6d1a@o1342815.ingest.sentry.io/6617119"
|
||||
MIXPANEL_API = "c79162511383b0fa1e9c062a2a86c855"
|
||||
TIME_FORM = os.environ.get("PGM_TIME_FORM", config["time_form"])
|
||||
DATE_FORM = os.environ.get("PGM_DATE_FORM", config["date_form"])
|
||||
|
@ -56,8 +56,11 @@ async def backup(message: Message):
|
||||
# run backup function
|
||||
make_tar_gz(pgm_backup_zip_name, ["data", "plugins", "config.yml"])
|
||||
if Config.LOG:
|
||||
try:
|
||||
await upload_attachment(pgm_backup_zip_name, Config.LOG_ID, None)
|
||||
await message.edit(lang("backup_success_channel"))
|
||||
except Exception:
|
||||
await message.edit(lang("backup_success"))
|
||||
else:
|
||||
await message.edit(lang("backup_success"))
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
import contextlib
|
||||
import importlib
|
||||
import os
|
||||
|
||||
import pagermaid.config
|
||||
import pagermaid.modules
|
||||
|
||||
@ -34,7 +36,7 @@ async def reload_all():
|
||||
for plugin_name in pagermaid.modules.plugin_list.copy():
|
||||
try:
|
||||
plugin = importlib.import_module(f"plugins.{plugin_name}")
|
||||
if plugin_name in loaded_plugins:
|
||||
if plugin_name in loaded_plugins and os.path.exists(plugin.__file__):
|
||||
importlib.reload(plugin)
|
||||
except BaseException as exception:
|
||||
logs.info(f"{lang('module')} {plugin_name} {lang('error')}: {exception}")
|
||||
|
@ -1,4 +1,8 @@
|
||||
import pyrogram
|
||||
from pyrogram.enums.auto_name import AutoName
|
||||
from pyrogram.errors import BadRequest, SessionPasswordNeeded
|
||||
from pyrogram.types import User, TermsOfService, SentCode
|
||||
from pyrogram.utils import ainput
|
||||
|
||||
|
||||
async def temp_fix(
|
||||
@ -17,3 +21,180 @@ async def temp_fix(
|
||||
parsed.reply_to_message_id = None
|
||||
parsed.reply_to_message = None
|
||||
return parsed
|
||||
|
||||
|
||||
class NewSentCodeType(AutoName):
|
||||
"""Sent code type enumeration used in :obj:`~pyrogram.types.SentCode`."""
|
||||
|
||||
APP = pyrogram.raw.types.auth.SentCodeTypeApp
|
||||
"The code was sent through the telegram app."
|
||||
|
||||
CALL = pyrogram.raw.types.auth.SentCodeTypeCall
|
||||
"The code will be sent via a phone call. A synthesized voice will tell the user which verification code to input."
|
||||
|
||||
FLASH_CALL = pyrogram.raw.types.auth.SentCodeTypeFlashCall
|
||||
"The code will be sent via a flash phone call, that will be closed immediately."
|
||||
|
||||
MISSED_CALL = pyrogram.raw.types.auth.SentCodeTypeMissedCall
|
||||
"Missed call."
|
||||
|
||||
SMS = pyrogram.raw.types.auth.SentCodeTypeSms
|
||||
"The code was sent via SMS."
|
||||
|
||||
FRAGMENT_SMS = pyrogram.raw.types.auth.SentCodeTypeFragmentSms
|
||||
"The code was sent via Fragment SMS."
|
||||
|
||||
|
||||
class NewNextCodeType(AutoName):
|
||||
"""Next code type enumeration used in :obj:`~pyrogram.types.SentCode`."""
|
||||
|
||||
CALL = pyrogram.raw.types.auth.CodeTypeCall
|
||||
"The code will be sent via a phone call. A synthesized voice will tell the user which verification code to input."
|
||||
|
||||
FLASH_CALL = pyrogram.raw.types.auth.CodeTypeFlashCall
|
||||
"The code will be sent via a flash phone call, that will be closed immediately."
|
||||
|
||||
MISSED_CALL = pyrogram.raw.types.auth.CodeTypeMissedCall
|
||||
"Missed call."
|
||||
|
||||
SMS = pyrogram.raw.types.auth.CodeTypeSms
|
||||
"The code was sent via SMS."
|
||||
|
||||
FRAGMENT_SMS = pyrogram.raw.types.auth.SentCodeTypeFragmentSms
|
||||
"The code was sent via Fragment SMS."
|
||||
|
||||
|
||||
def sent_code_parse(sent_code: pyrogram.raw.types.auth.SentCode):
|
||||
try:
|
||||
return SentCode.old_parse(sent_code) # noqa
|
||||
except Exception:
|
||||
return SentCode(
|
||||
type=NewSentCodeType(type(sent_code.type)), # noqa
|
||||
phone_code_hash=sent_code.phone_code_hash,
|
||||
next_type=NewNextCodeType(type(sent_code.next_type)) if sent_code.next_type else None,
|
||||
timeout=sent_code.timeout
|
||||
)
|
||||
|
||||
|
||||
async def fix_authorize(self: "pyrogram.Client"):
|
||||
if self.bot_token:
|
||||
return await self.sign_in_bot(self.bot_token)
|
||||
|
||||
print(f"Welcome to Pyrogram (version {pyrogram.__version__})")
|
||||
print(f"Pyrogram is free software and comes with ABSOLUTELY NO WARRANTY. Licensed\n"
|
||||
f"under the terms of the {pyrogram.__license__}.\n")
|
||||
|
||||
while True:
|
||||
try:
|
||||
if not self.phone_number:
|
||||
while True:
|
||||
value = await ainput("Enter phone number or bot token: ")
|
||||
|
||||
if not value:
|
||||
continue
|
||||
|
||||
confirm = (await ainput(f'Is "{value}" correct? (y/N): ')).lower()
|
||||
|
||||
if confirm == "y":
|
||||
break
|
||||
|
||||
if ":" in value:
|
||||
self.bot_token = value
|
||||
return await self.sign_in_bot(value)
|
||||
else:
|
||||
self.phone_number = value
|
||||
|
||||
sent_code = await self.send_code(self.phone_number)
|
||||
except BadRequest as e:
|
||||
print(e.MESSAGE)
|
||||
self.phone_number = None
|
||||
self.bot_token = None
|
||||
else:
|
||||
break
|
||||
|
||||
sent_code_descriptions = {
|
||||
pyrogram.enums.SentCodeType.APP: "Telegram app",
|
||||
pyrogram.enums.SentCodeType.SMS: "SMS",
|
||||
pyrogram.enums.SentCodeType.CALL: "phone call",
|
||||
pyrogram.enums.SentCodeType.FLASH_CALL: "phone flash call",
|
||||
NewSentCodeType.APP: "Telegram app",
|
||||
NewSentCodeType.SMS: "SMS",
|
||||
NewSentCodeType.CALL: "phone call",
|
||||
NewSentCodeType.FLASH_CALL: "phone flash call",
|
||||
NewSentCodeType.FRAGMENT_SMS: "fragment sms",
|
||||
}
|
||||
print(sent_code.type)
|
||||
print(sent_code.next_type)
|
||||
|
||||
print(f"The confirmation code has been sent via {sent_code_descriptions[sent_code.type]}")
|
||||
|
||||
while True:
|
||||
if not self.phone_code:
|
||||
self.phone_code = await ainput("Enter confirmation code: ")
|
||||
|
||||
try:
|
||||
signed_in = await self.sign_in(self.phone_number, sent_code.phone_code_hash, self.phone_code)
|
||||
except BadRequest as e:
|
||||
print(e.MESSAGE)
|
||||
self.phone_code = None
|
||||
except SessionPasswordNeeded as e:
|
||||
print(e.MESSAGE)
|
||||
|
||||
while True:
|
||||
print("Password hint: {}".format(await self.get_password_hint()))
|
||||
|
||||
if not self.password:
|
||||
self.password = await ainput("Enter password (empty to recover): ", hide=self.hide_password)
|
||||
|
||||
try:
|
||||
if not self.password:
|
||||
confirm = await ainput("Confirm password recovery (y/n): ")
|
||||
|
||||
if confirm == "y":
|
||||
email_pattern = await self.send_recovery_code()
|
||||
print(f"The recovery code has been sent to {email_pattern}")
|
||||
|
||||
while True:
|
||||
recovery_code = await ainput("Enter recovery code: ")
|
||||
|
||||
try:
|
||||
return await self.recover_password(recovery_code)
|
||||
except BadRequest as e:
|
||||
print(e.MESSAGE)
|
||||
except Exception as e:
|
||||
pyrogram.client.log.error(e, exc_info=True)
|
||||
raise
|
||||
else:
|
||||
self.password = None
|
||||
else:
|
||||
return await self.check_password(self.password)
|
||||
except BadRequest as e:
|
||||
print(e.MESSAGE)
|
||||
self.password = None
|
||||
else:
|
||||
break
|
||||
|
||||
if isinstance(signed_in, User):
|
||||
return signed_in
|
||||
|
||||
while True:
|
||||
first_name = await ainput("Enter first name: ")
|
||||
last_name = await ainput("Enter last name (empty to skip): ")
|
||||
|
||||
try:
|
||||
signed_up = await self.sign_up(
|
||||
self.phone_number,
|
||||
sent_code.phone_code_hash,
|
||||
first_name,
|
||||
last_name
|
||||
)
|
||||
except BadRequest as e:
|
||||
print(e.MESSAGE)
|
||||
else:
|
||||
break
|
||||
|
||||
if isinstance(signed_in, TermsOfService):
|
||||
print("\n" + signed_in.text + "\n")
|
||||
await self.accept_terms_of_service(signed_in.id)
|
||||
|
||||
return signed_up
|
||||
|
@ -1,4 +1,4 @@
|
||||
pyrogram==2.0.69
|
||||
pyrogram==2.0.70
|
||||
TgCrypto==1.2.5
|
||||
Pillow>=8.4.0
|
||||
pytz>=2021.3
|
||||
@ -8,5 +8,5 @@ psutil>=5.8.0
|
||||
httpx
|
||||
apscheduler
|
||||
sqlitedict
|
||||
casbin==1.17.4
|
||||
sentry-sdk==1.11.1
|
||||
casbin==1.17.5
|
||||
sentry-sdk==1.12.0
|
||||
|
Loading…
Reference in New Issue
Block a user