Spaces:
Sleeping
Sleeping
| # ===================================================== | |
| # Apckeyl Framework | |
| # Version 2.1 | |
| # telegram_bot.py | |
| # ===================================================== | |
| """ | |
| Telegram Bot. | |
| Точка входа Telegram Framework. | |
| Version 2.0 | |
| """ | |
| import os | |
| import asyncio | |
| from aiogram import Bot | |
| from aiogram import Dispatcher | |
| from telegram_controller import TelegramController | |
| # ----------------------------------------------------- | |
| # Telegram Secrets | |
| # ----------------------------------------------------- | |
| BOT_TOKEN = os.getenv( | |
| "BOT_TOKEN" | |
| ) | |
| if not BOT_TOKEN: | |
| raise RuntimeError( | |
| "BOT_TOKEN not found in Hugging Face Secrets." | |
| ) | |
| # ----------------------------------------------------- | |
| # Telegram Objects | |
| # ----------------------------------------------------- | |
| bot = Bot( | |
| token=BOT_TOKEN, | |
| ) | |
| dispatcher = Dispatcher() | |
| controller = TelegramController( | |
| bot=bot, | |
| dispatcher=dispatcher, | |
| ) | |
| # ----------------------------------------------------- | |
| # Main | |
| # ----------------------------------------------------- | |
| async def main(): | |
| print() | |
| print("====================================") | |
| print("Apckeyl Telegram Framework") | |
| print("Version 2.1") | |
| print("====================================") | |
| print() | |
| print("BOT_TOKEN loaded successfully.") | |
| await controller.start() | |
| # ----------------------------------------------------- | |
| if __name__ == "__main__": | |
| asyncio.run( | |
| main() | |
| ) |