From 98bf36ec00049d689a76734fada77f7853f671a4 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 10:53:23 +0700 Subject: [PATCH 01/10] [set] setup logger --- program/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/program/__init__.py b/program/__init__.py index e46644b..220da6e 100644 --- a/program/__init__.py +++ b/program/__init__.py @@ -1,3 +1,16 @@ __version__ = "0.6.5" +# >>> patch : F.11.22 -# update patch : F.11.22 +import time +import logging + +logging.basicConfig( + filename='bot.logs', + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' +) +logging.getLogger("yt_dlp").setLevel(logging.ERROR) +logging.getLogger("pyrogram").setLevel(logging.ERROR) +logging.getLogger("PyTgCalls").setLevel(logging.ERROR) + +LOGS = logging.getLogger(__name__) From 725e0669a3c682e980e0422e58a3eb0b3437fa7b Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 10:57:12 +0700 Subject: [PATCH 02/10] [set] setup logger --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 6b5d240..fe64802 100644 --- a/main.py +++ b/main.py @@ -1,17 +1,19 @@ import asyncio + +from program import LOGS from pytgcalls import idle from driver.core import calls, bot, user async def start_bot(): await bot.start() - print("[INFO]: BOT & UBOT CLIENT STARTED !!") + LOGS.info("[INFO]: BOT & USERBOT CLIENT STARTED !!") await calls.start() - print("[INFO]: PY-TGCALLS CLIENT STARTED !!") + LOGS.info("[INFO]: PY-TGCALLS CLIENT STARTED !!") await user.join_chat("VeezSupportGroup") await user.join_chat("levinachannel") await idle() - print("[INFO]: STOPPING BOT & USERBOT") + LOGS.info("[INFO]: BOT & USERBOT STOPPED !!") await bot.stop() loop = asyncio.get_event_loop() From 5dd6192801d92286c729e06aa5105264b4c23b4a Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 11:08:11 +0700 Subject: [PATCH 03/10] [set] setup logger --- program/sysinfo.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/program/sysinfo.py b/program/sysinfo.py index b86568c..bf5b36c 100644 --- a/program/sysinfo.py +++ b/program/sysinfo.py @@ -17,6 +17,7 @@ along with this program. If not, see Date: Fri, 25 Feb 2022 11:31:06 +0700 Subject: [PATCH 04/10] [check] some fixes --- program/sysinfo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/program/sysinfo.py b/program/sysinfo.py index bf5b36c..72bdf42 100644 --- a/program/sysinfo.py +++ b/program/sysinfo.py @@ -25,16 +25,16 @@ import psutil import platform from config import BOT_USERNAME - from driver.filters import command from driver.decorators import sudo_users_only, humanbytes from pyrogram import Client, filters +from pyrogram.types import Message @Client.on_message(command(["sysinfo", f"sysinfo@{BOT_USERNAME}"]) & ~filters.edited) @sudo_users_only -async def give_sysinfo(client, message): +async def give_sysinfo(c: Client, message: Message): splatform = platform.system() platform_release = platform.release() platform_version = platform.version() From 01d55a1c30070dbf6c3d9adcdf2f8d3279ca5498 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 11:32:43 +0700 Subject: [PATCH 05/10] [add] command info --- program/callback.py | 1 + 1 file changed, 1 insertion(+) diff --git a/program/callback.py b/program/callback.py index bd49ac1..c750dbe 100644 --- a/program/callback.py +++ b/program/callback.py @@ -231,6 +231,7 @@ async def sudo_set(_, query: CallbackQuery): » /blocklist - show you the list of all blacklisted chat » /speedtest - run the bot server speedtest » /sysinfo - show the system information +» /logs - generate the current bot logs » /eval - execute any code (`developer stuff`) » /sh - run any command (`developer stuff`) From d298e315c00f57d1f02a5d90c6d1afcbb3c4a633 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 11:47:13 +0700 Subject: [PATCH 06/10] [check] some changes --- program/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/program/__init__.py b/program/__init__.py index 220da6e..c062b61 100644 --- a/program/__init__.py +++ b/program/__init__.py @@ -4,8 +4,12 @@ __version__ = "0.6.5" import time import logging +from driver.core import me_bot + +id = me_bot.id + logging.basicConfig( - filename='bot.logs', + filename=f'streambot-logs-{id}.txt', level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) From 03a160830f1b51a19bb6dd70668d6a78fb4a7733 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 11:53:35 +0700 Subject: [PATCH 07/10] [check] some changes --- program/sysinfo.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/program/sysinfo.py b/program/sysinfo.py index 72bdf42..a86df0b 100644 --- a/program/sysinfo.py +++ b/program/sysinfo.py @@ -25,7 +25,11 @@ import psutil import platform from config import BOT_USERNAME + +from program import LOGS +from driver.core import me_bot from driver.filters import command +from driver.utils import remove_if_exists from driver.decorators import sudo_users_only, humanbytes from pyrogram import Client, filters @@ -74,7 +78,8 @@ async def give_sysinfo(c: Client, message: Message): @Client.on_message(command(["logs", f"logs@{BOT_USERNAME}"]) & ~filters.edited) @sudo_users_only async def get_bot_logs(c: Client, m: Message): - bot_log_path = 'bot.logs' + id = me_bot.id + bot_log_path = f'streambot-logs-{id}.txt' if os.path.exists(bot_log_path): try: await m.reply_document( @@ -82,7 +87,8 @@ async def get_bot_logs(c: Client, m: Message): quote=True, caption='📄 This is the bot logs', ) - except BaseException: - os.remove(bot_log_path) + remove_if_exists(bot_log_path) + except BaseException as err: + LOGS.info(f'[ERROR]: {err}') if not os.path.exists(bot_log_path): await m.reply_text('❌ no logs found !') From 3b0c614dd99313598bb9caf8a9a3239567a9b80d Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 14:00:04 +0700 Subject: [PATCH 08/10] [check] some fixes --- program/sysinfo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/program/sysinfo.py b/program/sysinfo.py index a86df0b..4be27be 100644 --- a/program/sysinfo.py +++ b/program/sysinfo.py @@ -90,5 +90,6 @@ async def get_bot_logs(c: Client, m: Message): remove_if_exists(bot_log_path) except BaseException as err: LOGS.info(f'[ERROR]: {err}') - if not os.path.exists(bot_log_path): - await m.reply_text('❌ no logs found !') + else: + if not os.path.exists(bot_log_path): + await m.reply_text('❌ no logs found !') From f5209cc705ba993c9bcb289112d14e26f3d5a4a9 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 14:11:34 +0700 Subject: [PATCH 09/10] [check] some fixes --- program/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/program/__init__.py b/program/__init__.py index c062b61..19694be 100644 --- a/program/__init__.py +++ b/program/__init__.py @@ -6,10 +6,8 @@ import logging from driver.core import me_bot -id = me_bot.id - logging.basicConfig( - filename=f'streambot-logs-{id}.txt', + filename=f'streambot-logs-{me_bot.id}.txt', level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) From d7f8b2b50550155ab8260344c547c16e3f136f0a Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 25 Feb 2022 14:12:17 +0700 Subject: [PATCH 10/10] [check] some fixes --- program/sysinfo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/program/sysinfo.py b/program/sysinfo.py index 4be27be..f030153 100644 --- a/program/sysinfo.py +++ b/program/sysinfo.py @@ -78,8 +78,7 @@ async def give_sysinfo(c: Client, message: Message): @Client.on_message(command(["logs", f"logs@{BOT_USERNAME}"]) & ~filters.edited) @sudo_users_only async def get_bot_logs(c: Client, m: Message): - id = me_bot.id - bot_log_path = f'streambot-logs-{id}.txt' + bot_log_path = f'streambot-logs-{me_bot.id}.txt' if os.path.exists(bot_log_path): try: await m.reply_document(