From bc30e1cf4571693fa84337b61c18470ae8fcff69 Mon Sep 17 00:00:00 2001 From: Santiago Ramirez Date: Wed, 11 Oct 2023 05:03:14 +0000 Subject: [PATCH] Pruned old config --- .gitignore | 12 ++++------ bot/__init__.py | 4 ++-- bot/__main__.py | 26 ++++++++------------- bot/callbacks/misc.py | 2 +- bot/{plugins => }/commands/actives.py | 0 bot/{plugins => }/commands/config.py | 0 bot/{plugins => }/commands/help.py | 0 bot/{plugins => }/commands/join.py | 0 bot/{plugins => }/commands/leave.py | 0 bot/{plugins => }/commands/logs.py | 0 bot/{plugins => }/commands/ping.py | 0 bot/{plugins => }/commands/play_book.py | 0 bot/{plugins => }/commands/play_song.py | 0 bot/{plugins => }/commands/play_video.py | 0 bot/{plugins => }/commands/speedtest.py | 0 bot/{plugins => }/commands/start.py | 0 bot/{plugins => }/commands/streaming.py | 0 bot/setup.py | 17 ++------------ bot/{plugins/filters => tasks}/on_joined.py | 0 session/session.py | 2 -- 20 files changed, 19 insertions(+), 44 deletions(-) rename bot/{plugins => }/commands/actives.py (100%) rename bot/{plugins => }/commands/config.py (100%) rename bot/{plugins => }/commands/help.py (100%) rename bot/{plugins => }/commands/join.py (100%) rename bot/{plugins => }/commands/leave.py (100%) rename bot/{plugins => }/commands/logs.py (100%) rename bot/{plugins => }/commands/ping.py (100%) rename bot/{plugins => }/commands/play_book.py (100%) rename bot/{plugins => }/commands/play_song.py (100%) rename bot/{plugins => }/commands/play_video.py (100%) rename bot/{plugins => }/commands/speedtest.py (100%) rename bot/{plugins => }/commands/start.py (100%) rename bot/{plugins => }/commands/streaming.py (100%) rename bot/{plugins/filters => tasks}/on_joined.py (100%) diff --git a/.gitignore b/.gitignore index 1d56b0d..05908c1 100755 --- a/.gitignore +++ b/.gitignore @@ -2,16 +2,12 @@ tmp logs cache downloads -__pycache__ -kreacher_env -unknown_errors.txt +*.env +*.log +*.lock +*.pyc *.session *.session-journal -.env .codesandbox - -*.lock - -tg-codes diff --git a/bot/__init__.py b/bot/__init__.py index dcd6f51..a6d8623 100755 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -38,12 +38,12 @@ if os.path.exists(_logs_file) and os.stat(_logs_file).st_size > 0: with open(_logs_file, "w") as f: f.truncate(0) - print(f'{colored("[INFO]", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY') + print(f'{colored("[INFO]:", "blue")}: LOG FILE WAS FLUSHED SUCCESSFULLY') elif not os.path.exists(_logs_file): try: with open(_logs_file, "w") as f: f.write("") - print(f'{colored("[INFO]", "blue")}: LOG FILE CREATED') + print(f'{colored("[INFO]:", "blue")} LOG FILE CREATED') except Exception as e: logging.error(e) diff --git a/bot/__main__.py b/bot/__main__.py index 0d0d6ea..9612745 100755 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -3,7 +3,7 @@ from termcolor import colored from pyrogram.types import BotCommand -from bot.setup import setup_plugins +from bot.setup import setup_plugins from bot import kreacher, assistant ay = asyncio.get_event_loop() @@ -29,18 +29,12 @@ async def start_bot(): print(f'{colored("[INFO]", "blue")}: SETED BOT COMMANDS') -# setup_db() -setup_plugins() -ay.run_until_complete(start_bot()) - -print(f'{colored("[INFO]", "blue")}: SUCCESSFULLY STARTED BOT!') - -if __name__ == "__main__": - try: - idle() - except KeyboardInterrupt: - pass - finally: - kreacher.disconnect() - assistant.disconnect() - print(f'{colored("[INFO]", "blue")}: CLIENTS DISCONNECTED') +try: + setup_plugins() + ay.run_until_complete(start_bot()) + print(f'{colored("[INFO]", "blue")}: SUCCESSFULLY STARTED BOT!') + idle() +except KeyboardInterrupt: + kreacher.disconnect() + assistant.disconnect() + print(f'{colored("[INFO]", "blue")}: CLIENTS DISCONNECTED') diff --git a/bot/callbacks/misc.py b/bot/callbacks/misc.py index 13c7f9e..c5cd6b2 100755 --- a/bot/callbacks/misc.py +++ b/bot/callbacks/misc.py @@ -8,7 +8,7 @@ from bot.config import config -from bot.plugins.commands.start import PM_START_TEXT +from bot.commands.start import PM_START_TEXT from bot import kreacher, execution_time, START_TIME thumb = "https://telegra.ph/file/3e14128ad5c9ec47801bd.jpg" diff --git a/bot/plugins/commands/actives.py b/bot/commands/actives.py similarity index 100% rename from bot/plugins/commands/actives.py rename to bot/commands/actives.py diff --git a/bot/plugins/commands/config.py b/bot/commands/config.py similarity index 100% rename from bot/plugins/commands/config.py rename to bot/commands/config.py diff --git a/bot/plugins/commands/help.py b/bot/commands/help.py similarity index 100% rename from bot/plugins/commands/help.py rename to bot/commands/help.py diff --git a/bot/plugins/commands/join.py b/bot/commands/join.py similarity index 100% rename from bot/plugins/commands/join.py rename to bot/commands/join.py diff --git a/bot/plugins/commands/leave.py b/bot/commands/leave.py similarity index 100% rename from bot/plugins/commands/leave.py rename to bot/commands/leave.py diff --git a/bot/plugins/commands/logs.py b/bot/commands/logs.py similarity index 100% rename from bot/plugins/commands/logs.py rename to bot/commands/logs.py diff --git a/bot/plugins/commands/ping.py b/bot/commands/ping.py similarity index 100% rename from bot/plugins/commands/ping.py rename to bot/commands/ping.py diff --git a/bot/plugins/commands/play_book.py b/bot/commands/play_book.py similarity index 100% rename from bot/plugins/commands/play_book.py rename to bot/commands/play_book.py diff --git a/bot/plugins/commands/play_song.py b/bot/commands/play_song.py similarity index 100% rename from bot/plugins/commands/play_song.py rename to bot/commands/play_song.py diff --git a/bot/plugins/commands/play_video.py b/bot/commands/play_video.py similarity index 100% rename from bot/plugins/commands/play_video.py rename to bot/commands/play_video.py diff --git a/bot/plugins/commands/speedtest.py b/bot/commands/speedtest.py similarity index 100% rename from bot/plugins/commands/speedtest.py rename to bot/commands/speedtest.py diff --git a/bot/plugins/commands/start.py b/bot/commands/start.py similarity index 100% rename from bot/plugins/commands/start.py rename to bot/commands/start.py diff --git a/bot/plugins/commands/streaming.py b/bot/commands/streaming.py similarity index 100% rename from bot/plugins/commands/streaming.py rename to bot/commands/streaming.py diff --git a/bot/setup.py b/bot/setup.py index fb7af58..2c451dd 100755 --- a/bot/setup.py +++ b/bot/setup.py @@ -1,25 +1,12 @@ -import os import sys import logging import importlib -from glob import glob from pathlib import Path from termcolor import colored -""" -from bot import db_metadata, engine - - -def setup_db(): - db_metadata.create_all(engine) -""" def setup_plugins(): - cwd = os.path.dirname(os.path.abspath(__file__)) - folders = ["callbacks", "tasks"] - folders.extend(glob(f"{cwd}/plugins/*", recursive=True)) - for e in glob(f"{cwd}/plugins/*", recursive=True): - folders.append(e.split("/", 3)[3]) + folders = ["callbacks", "commands", "tasks"] for folder in folders: folder_path = Path(f"bot/{folder}") for file in folder_path.glob("*.py"): @@ -32,5 +19,5 @@ def setup_plugins(): sys.modules[module_name] = module print( - f'{colored("[INFO]", "blue")}: Bot has started {colored(module_name.replace("/", "."), "yellow")}' + f"{colored('[INFO]', 'blue')}: Bot has started {colored(module_name, 'yellow')}" ) diff --git a/bot/plugins/filters/on_joined.py b/bot/tasks/on_joined.py similarity index 100% rename from bot/plugins/filters/on_joined.py rename to bot/tasks/on_joined.py diff --git a/session/session.py b/session/session.py index 13b6bb5..68ced4a 100755 --- a/session/session.py +++ b/session/session.py @@ -11,6 +11,4 @@ with app: print(app.export_session_string()) except KeyboardInterrupt: - pass - finally: sys.exit(print("\n\nAborted!"))