From e8de8f80271b85ade0fe085bf66ea98fa3ee0459 Mon Sep 17 00:00:00 2001 From: Llloooggg Date: Sat, 19 Nov 2022 19:41:08 +0300 Subject: [PATCH] =?UTF-8?q?telegram:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20FastAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- telegram/requirements.txt | 23 +++++++++++++++++++ .../textsouls/handlers/character_creation.py | 4 ++-- telegram/textsouls/handlers/control.py | 6 ++--- telegram/textsouls/main.py | 22 ++++++------------ 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/telegram/requirements.txt b/telegram/requirements.txt index 7adb59c..d63e4f4 100644 --- a/telegram/requirements.txt +++ b/telegram/requirements.txt @@ -2,21 +2,44 @@ aiofiles==22.1.0 aiogram==3.0.0b6 aiohttp==3.8.3 aiosignal==1.3.1 +anyio==3.6.2 async-timeout==4.0.2 attrs==22.1.0 Babel==2.9.1 cachetools==4.2.4 certifi==2022.9.24 charset-normalizer==2.1.1 +click==8.1.3 +dnspython==2.2.1 +email-validator==1.3.0 +fastapi==0.87.0 frozenlist==1.3.3 +h11==0.14.0 +httpcore==0.16.1 +httptools==0.5.0 +httpx==0.23.1 idna==3.4 +itsdangerous==2.1.2 Jinja2==3.1.2 magic-filter==1.0.9 MarkupSafe==2.1.1 multidict==6.0.2 +orjson==3.8.1 pydantic==1.10.2 +python-dotenv==0.21.0 +python-multipart==0.0.5 pytz==2022.6 +PyYAML==6.0 requests==2.28.1 +rfc3986==1.5.0 +six==1.16.0 +sniffio==1.3.0 +starlette==0.21.0 typing-extensions==4.4.0 +ujson==5.5.0 urllib3==1.26.12 +uvicorn==0.19.0 +uvloop==0.17.0 +watchfiles==0.18.1 +websockets==10.4 yarl==1.8.1 diff --git a/telegram/textsouls/handlers/character_creation.py b/telegram/textsouls/handlers/character_creation.py index ccf2ba2..767ab30 100644 --- a/telegram/textsouls/handlers/character_creation.py +++ b/telegram/textsouls/handlers/character_creation.py @@ -2,8 +2,8 @@ from aiogram import Router from aiogram.filters import Command from aiogram.fsm.state import StatesGroup, State -from common import backend -from keyboards.common import row_kb +from textsouls.common import backend +from textsouls.keyboards.common import row_kb router = Router() diff --git a/telegram/textsouls/handlers/control.py b/telegram/textsouls/handlers/control.py index 138aa24..18da026 100644 --- a/telegram/textsouls/handlers/control.py +++ b/telegram/textsouls/handlers/control.py @@ -1,10 +1,10 @@ from aiogram import Router from aiogram.filters import Command -from common import backend +from textsouls.common import backend -from handlers.character_creation import CharachterCreation -from handlers.character_creation import character_creation +from textsouls.handlers.character_creation import CharachterCreation +from textsouls.handlers.character_creation import character_creation router = Router() diff --git a/telegram/textsouls/main.py b/telegram/textsouls/main.py index 167af16..938545c 100644 --- a/telegram/textsouls/main.py +++ b/telegram/textsouls/main.py @@ -1,27 +1,19 @@ import json -import asyncio +from fastapi import FastAPI from aiogram import Bot, Dispatcher from aiogram.fsm.storage.memory import MemoryStorage -from handlers import control -from handlers import character_creation - with open("textsouls/config.json") as config_file: config_data = json.load(config_file) +app = FastAPI() -async def main(): - bot = Bot(token=config_data["MAIN_SETTINGS"]["BOT_TOKEN"]) - dp = Dispatcher(storage=MemoryStorage()) - - dp.include_router(control.router) - dp.include_router(character_creation.router) - - await bot.delete_webhook(drop_pending_updates=True) - await dp.start_polling(bot) +bot = Bot(token=config_data["MAIN_SETTINGS"]["BOT_TOKEN"]) +dp = Dispatcher(storage=MemoryStorage()) -if __name__ == "__main__": - asyncio.run(main()) +@app.get("/") +async def root(): + return {"message": "Hello World"}