Files
Stan-Ansible/src/webhook.py
T

22 lines
482 B
Python

import asyncio
import logging
import telebot
from fastapi import FastAPI
from .commands import bot
from .config import TOKEN
logging.warning("[START] Webhook server")
app = FastAPI(docs=None, redoc_url=None)
@app.post(f"/bot{TOKEN}/")
async def webhook(update: dict):
"""Parse POST requests from Telegram."""
if update:
update = telebot.types.Update.de_json(update)
asyncio.ensure_future(bot.process_new_updates([update]))
else:
return None