diff options
Diffstat (limited to 'bot.py')
-rw-r--r-- | bot.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -8,7 +8,7 @@ from config import BOT_TOKEN, TELEGRAM_WEBHOOK_URL, HEALTHCHECK_URL, FEDI_LOGIN_ | |||
8 | import uvicorn | 8 | import uvicorn |
9 | from starlette.applications import Starlette | 9 | from starlette.applications import Starlette |
10 | from starlette.requests import Request | 10 | from starlette.requests import Request |
11 | from starlette.responses import PlainTextResponse, Response | 11 | from starlette.responses import PlainTextResponse, Response, JSONResponse |
12 | from starlette.routing import Route | 12 | from starlette.routing import Route |
13 | from telegram import Update | 13 | from telegram import Update |
14 | from telegram.ext import ( | 14 | from telegram.ext import ( |
@@ -188,12 +188,12 @@ async def main() -> None: | |||
188 | await application.bot.set_webhook(url=f"{BOT_DOMAIN}{TELEGRAM_WEBHOOK_URL}") | 188 | await application.bot.set_webhook(url=f"{BOT_DOMAIN}{TELEGRAM_WEBHOOK_URL}") |
189 | 189 | ||
190 | # Set up webserver | 190 | # Set up webserver |
191 | async def telegram_webhook(request: Request) -> Response: | 191 | async def telegram_webhook(request: Request) -> JSONResponse: |
192 | """Handle incoming Telegram updates by putting them into the `update_queue`""" | 192 | """Handle incoming Telegram updates by putting them into the `update_queue`""" |
193 | await application.update_queue.put( | 193 | await application.update_queue.put( |
194 | Update.de_json(data=await request.json(), bot=application.bot) | 194 | Update.de_json(data=await request.json(), bot=application.bot) |
195 | ) | 195 | ) |
196 | return Response() | 196 | return JSONResponse({'OK': 200}) |
197 | 197 | ||
198 | async def fedi_oauth_login_callback(request: Request) -> PlainTextResponse: | 198 | async def fedi_oauth_login_callback(request: Request) -> PlainTextResponse: |
199 | """ | 199 | """ |
@@ -221,7 +221,7 @@ async def main() -> None: | |||
221 | routes=[ | 221 | routes=[ |
222 | Route(TELEGRAM_WEBHOOK_URL, telegram_webhook, methods=["POST"]), | 222 | Route(TELEGRAM_WEBHOOK_URL, telegram_webhook, methods=["POST"]), |
223 | Route(HEALTHCHECK_URL, healthcheck, methods=["GET"]), | 223 | Route(HEALTHCHECK_URL, healthcheck, methods=["GET"]), |
224 | Route(FEDI_LOGIN_CALLBACK_URL, fedi_oauth_login_callback, methods=["POST", "GET"]), | 224 | Route(FEDI_LOGIN_CALLBACK_URL, fedi_oauth_login_callback, methods=["GET"]), |
225 | ] | 225 | ] |
226 | ) | 226 | ) |
227 | webserver = uvicorn.Server( | 227 | webserver = uvicorn.Server( |