|
import logging |
|
from contextlib import asynccontextmanager |
|
from akenoai import AkenoXToJs as js |
|
from akenoai.runner import run_fast |
|
from config import API_ID, API_HASH, BOT_TOKEN |
|
|
|
logger = logging.getLogger(__name__) |
|
LOGS = logging.getLogger("[akenox]") |
|
logger.setLevel(logging.DEBUG) |
|
|
|
fast_app = js.get_app() |
|
|
|
client = js.create_pyrogram( |
|
name="fastapi-bot", |
|
api_id=API_ID, |
|
api_hash=API_HASH, |
|
bot_token=BOT_TOKEN |
|
) |
|
|
|
@fast_app.on_event("startup") |
|
async def startup_event(): |
|
user = await client.start() |
|
LOGS.info(f"Started Bot: {user.me.first_name}") |
|
|
|
@fast_app.get("/") |
|
async def hello(): |
|
return {"success": response_json} |
|
|
|
@fast_app.get("/api/send") |
|
async def send_message(): |
|
response_json = await client.send_message("@xpushz", "hello world!") |
|
return {"success": response_json} |
|
|
|
run_fast(build=fast_app, port=7860) |