From a1f2a502fe06b345ac62286a6eec4ebf54896c5f Mon Sep 17 00:00:00 2001 From: Jayant Hegde Kageri Date: Fri, 1 Oct 2021 09:26:44 +0530 Subject: [PATCH] Release Bug Fix Update v1.2.4 For changelog: https://github.com/jayantkageri/tgEasy/releases/tag/v1.2.4 --- .gitignore | 1 + README.md | 2 +- setup.py | 2 +- tgEasy/__init__.py | 30 +++++++++++++++--------------- tgEasy/config.py | 3 ++- tgEasy/decorater.py | 15 +++++++++------ tgEasy/scaffold.py | 5 ++++- 7 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 11d96d8..017133e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +*.toml # Environments diff --git a/README.md b/README.md index a8a4f49..246d039 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ along with tgEasy. If not, see . # tgEasy ```python -from tgEasy import tgClient, command +from tgEasy import tgClient from pyrogram import Client app = tgClient(Client("my_account")) diff --git a/setup.py b/setup.py index 0f00e91..6d5afb8 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", ], - keywords="telegram chat messenger mtproto api client library python pyrogram tgeasy monkey patcher", + keywords="telegram chat messenger mtproto api client library python pyrogram tgeasy", project_urls={ "Tracker": "https://github.com/jayantkageri/tgEasys/issues", "Community": "https://telegram.me/tgEasyNews", diff --git a/tgEasy/__init__.py b/tgEasy/__init__.py index 2cba347..c574c9d 100644 --- a/tgEasy/__init__.py +++ b/tgEasy/__init__.py @@ -32,7 +32,7 @@ from .decorater import * from .helpers import * -__version__ = "1.2.3" +__version__ = "1.2.4" __copyright__ = "Copyright 2021 Jayant Hegde Kageri " __license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)" logging = logger.getLogger("tgEasy") @@ -49,26 +49,26 @@ class Methods( class tgClient(Methods, Scaffold): notice_displayed = False - """ -### `tgEasy.tgClient` -- A Class for Initialising the tgEasy and it's Methods, Types and Functions -- Parameters: - - client (`pyrogram.Client`): - - The Pyrogram Client - -#### Example -.. code-block:: python - from tgEasy import tgClient - from pyrogram import Client - - app = tgClient(Client("my_account")) - """ __client__ = None def __init__( self, client=pyrogram.Client ): + """ + ### `tgEasy.tgClient` + - A Class for Initialising the tgEasy and it's Methods, Types and Functions + - Parameters: + - client (`pyrogram.Client`): + - The Pyrogram Client + + #### Example + .. code-block:: python + from tgEasy import tgClient + from pyrogram import Client + + app = tgClient(Client("my_account")) + """ super().__init__() self.__client__ = client tgClient.__client__ = self.__client__ diff --git a/tgEasy/config.py b/tgEasy/config.py index 3c80e31..2a4ddfd 100644 --- a/tgEasy/config.py +++ b/tgEasy/config.py @@ -17,8 +17,9 @@ # along with tgEasy. If not, see . import os + from prettyconf import Configuration -from prettyconf.loaders import Environment, EnvFile +from prettyconf.loaders import EnvFile, Environment env_file = f"{os.getcwd()}/.env" config = Configuration(loaders=[Environment(), EnvFile(filename=env_file)]) diff --git a/tgEasy/decorater.py b/tgEasy/decorater.py index 8514b0a..e64f8c3 100644 --- a/tgEasy/decorater.py +++ b/tgEasy/decorater.py @@ -17,12 +17,15 @@ # along with tgEasy. If not, see . import os -import tgEasy import typing + import pyrogram + +import tgEasy +from tgEasy.scaffold import Scaffold + from .config import Config from .helpers import * -from tgEasy.scaffold import Scaffold class Command(Scaffold): @@ -91,7 +94,7 @@ async def decorator(client, message: pyrogram.types.Message): return await message.reply_text("This command can be used in PMs only.") try: await func(client, message) - except pyrogram.errors.forbidden_403.ChatWriteForbidden: + except pyrogram.errors.exceptions.forbidden_403.ChatWriteForbidden: await client.leave_chat(message.chat.id) except BaseException as exception: return await handle_error(exception, message) @@ -149,9 +152,9 @@ def wrapper(func): async def decorator(client, CallbackQuery: pyrogram.types.CallbackQuery): if self_admin: me = await client.get_me() - mee = await client.get_chat_member(message.chat.id, me.id) + mee = await client.get_chat_member(CallbackQuery.chat.id, me.id) if not mee.status == "admin": - return await message.reply_text("I must be admin to execute this Command") + return await CallbackQuery.message.edit_text("I must be admin to execute this Command") pass try: await func(client, CallbackQuery) @@ -205,7 +208,7 @@ async def decorator(client, message): return await message.reply_text(f"You are Missing the following Rights to use this Command:\n{permission}") try: await func(client, message) - except pyrogram.errors.exception.forbidden_403.ChatWriteForbidden: + except pyrogram.errors.exceptions.forbidden_403.ChatWriteForbidden: await client.leave_chat(message.chat.id) except BaseException as exception: await handle_error(exception, message) diff --git a/tgEasy/scaffold.py b/tgEasy/scaffold.py index 8460823..e399c0c 100644 --- a/tgEasy/scaffold.py +++ b/tgEasy/scaffold.py @@ -3,9 +3,12 @@ import platform import re import sys + import pyrogram + import tgEasy + class Scaffold: def __init__(self): try: @@ -30,4 +33,4 @@ async def check_rights(*args, **kwargs): pass async def is_admin(*args, **kwargs): - pass \ No newline at end of file + pass