Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Raise Exception before sending logs to chat.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantkageri committed Apr 24, 2022
1 parent d9381d4 commit 15be79d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with tgEasy. If not, see <http://www.gnu.org/licenses/>.

import os
import re
import shutil
from sys import argv

from setuptools import find_packages, setup

Expand All @@ -30,7 +27,7 @@
readme = f.read()

with open("requirements.txt", encoding="utf-8") as f:
requirements = f.read().splitlines()
requires = f.read().splitlines()

setup(
name="tgEasy",
Expand Down Expand Up @@ -74,5 +71,5 @@
python_requires="~=3.6",
packages=find_packages(),
zip_safe=False,
install_requires=requirements,
install_requires=requires,
)
10 changes: 5 additions & 5 deletions tgEasy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import asyncio
import logging as logger
from datetime import datetime

import pyrogram
from pyrogram import client
Expand All @@ -32,7 +33,7 @@
from .scaffold import Scaffold

__version__ = "1.3.1"
__copyright__ = "Copyright 2021 Jayant Hegde Kageri <github.com/jayantkageri>"
__copyright__ = f"Copyright 2021 - {datetime.now().year} Jayant Hegde Kageri <github.com/jayantkageri>"
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
logging = logger.getLogger("tgEasy")
main_event_loop = asyncio.get_event_loop()
Expand Down Expand Up @@ -91,10 +92,9 @@ def run(self):
logging.info("Starting the pyrogram.Client")
try:
self.__client__.start()
self.__client__.send_message(
Config.LOGS, "pyrogram.Client Started")
self.__client__.send_message(Config.LOGS, "pyrogram.Client Started")
except pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid:
logging.warning("Interact the Bot to your Log Group Now")
logging.warning("Interact the Bot to your Log Chat Now")
pass
logging.info("Started the pyrogram.Client")
logging.info("Idling the pyrogram.Client")
Expand All @@ -106,7 +106,7 @@ def run(self):
)
except pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid:
logging.warning(
"Unable to Send Message to Log Group, Please Interact Bot with the Log Group while Running"
"Unable to Send Message to Log Chat, Please Interact Bot with the Log Group while Running"
)
pass
logging.info("Stopping the pyrogram.Client")
Expand Down
3 changes: 2 additions & 1 deletion tgEasy/helpers/handle_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ async def start(client, message):

from .. import logging

logging.exception(traceback.format_exc())

with open("crash.log", "w+", encoding="utf-8") as log:
log.write(traceback.format_exc())
log.close()
Expand All @@ -82,6 +84,5 @@ async def start(client, message):
)
except:
pass
logging.exception(traceback.format_exc())
os.remove("crash.log")
return True

0 comments on commit 15be79d

Please sign in to comment.