diff --git a/apps/tgbot/config.py b/apps/tgbot/config.py deleted file mode 100644 index 3629903..0000000 --- a/apps/tgbot/config.py +++ /dev/null @@ -1,10 +0,0 @@ -import os - -from dotenv import load_dotenv - -dotenv_path = os.path.join(os.path.dirname(__file__), '.env') -if os.path.exists(dotenv_path): - load_dotenv(dotenv_path) - -# Loading token from .env -TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN") diff --git a/apps/tgbot/handlers/__init__.py b/apps/tgbot/handlers/__init__.py deleted file mode 100644 index 446e418..0000000 --- a/apps/tgbot/handlers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import default \ No newline at end of file diff --git a/apps/tgbot/__init__.py b/apps/tgbot/tgbot/__init__.py similarity index 100% rename from apps/tgbot/__init__.py rename to apps/tgbot/tgbot/__init__.py diff --git a/apps/tgbot/bot.py b/apps/tgbot/tgbot/bot.py similarity index 76% rename from apps/tgbot/bot.py rename to apps/tgbot/tgbot/bot.py index d041b76..3bb6533 100644 --- a/apps/tgbot/bot.py +++ b/apps/tgbot/tgbot/bot.py @@ -1,6 +1,5 @@ from aiogram import Bot, Dispatcher, executor from aiogram.contrib.fsm_storage.memory import MemoryStorage -from loguru import logger import config import handlers @@ -9,10 +8,11 @@ storage = MemoryStorage() telegram_bot = Bot(token=config.TELEGRAM_BOT_TOKEN) dp = Dispatcher(telegram_bot, storage=storage) + def on_startup(): - logger.info('Registering handlers') handlers.default.setup(dp) + if __name__ == '__main__': on_startup() - executor.start_polling(dp,skip_updates=True) \ No newline at end of file + executor.start_polling(dp, skip_updates=True) diff --git a/apps/tgbot/tgbot/config.py b/apps/tgbot/tgbot/config.py new file mode 100644 index 0000000..35a1d12 --- /dev/null +++ b/apps/tgbot/tgbot/config.py @@ -0,0 +1,4 @@ +import os + +# Loading token from .env +TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN") diff --git a/apps/tgbot/tgbot/handlers/__init__.py b/apps/tgbot/tgbot/handlers/__init__.py new file mode 100644 index 0000000..19b07f3 --- /dev/null +++ b/apps/tgbot/tgbot/handlers/__init__.py @@ -0,0 +1 @@ +from . import default diff --git a/apps/tgbot/handlers/default/__init__.py b/apps/tgbot/tgbot/handlers/default/__init__.py similarity index 99% rename from apps/tgbot/handlers/default/__init__.py rename to apps/tgbot/tgbot/handlers/default/__init__.py index 0e3a5d3..b63c4a9 100644 --- a/apps/tgbot/handlers/default/__init__.py +++ b/apps/tgbot/tgbot/handlers/default/__init__.py @@ -2,5 +2,6 @@ from aiogram import Dispatcher from .start import start_cmd + def setup(dp: Dispatcher): dp.register_message_handler(start_cmd, commands=['start']) diff --git a/apps/tgbot/handlers/default/start.py b/apps/tgbot/tgbot/handlers/default/start.py similarity index 55% rename from apps/tgbot/handlers/default/start.py rename to apps/tgbot/tgbot/handlers/default/start.py index 00298d4..7f7fc9b 100644 --- a/apps/tgbot/handlers/default/start.py +++ b/apps/tgbot/tgbot/handlers/default/start.py @@ -1,7 +1,5 @@ from aiogram.types import Message -from loguru import logger async def start_cmd(msg: Message): - logger.info(f"{msg.from_user.full_name} send /start") await msg.answer("Basic reply") \ No newline at end of file