Skip to content

Commit

Permalink
Pruned old config
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 11, 2023
1 parent 26f086e commit bc30e1c
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 44 deletions.
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
26 changes: 10 additions & 16 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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')
2 changes: 1 addition & 1 deletion bot/callbacks/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 2 additions & 15 deletions bot/setup.py
Original file line number Diff line number Diff line change
@@ -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"):
Expand All @@ -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')}"
)
File renamed without changes.
2 changes: 0 additions & 2 deletions session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
with app:
print(app.export_session_string())
except KeyboardInterrupt:
pass
finally:
sys.exit(print("\n\nAborted!"))

0 comments on commit bc30e1c

Please sign in to comment.