diff options
author | clarkzjw <[email protected]> | 2023-02-24 00:51:04 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-24 00:51:04 -0800 |
commit | 4bb5cbdc16ecf5f6e5961373816d4c741d54ee51 (patch) | |
tree | ea85f216881bacb54f579cae9814e2f85aa1abe5 /bot.py | |
parent | a9fb6f252553ae49a2ba372434073824babe31e4 (diff) | |
parent | 391abe42adf3bf065d9543ada068b696b00efdcd (diff) | |
download | swarm2fediverse-4bb5cbdc16ecf5f6e5961373816d4c741d54ee51.tar.gz |
Merge branch 'deploy/cicd'
added Dockerfile and docker-compose.yaml with krakend api gateway and
monitoring using influxdb and grafana dashboard
Diffstat (limited to 'bot.py')
-rw-r--r-- | bot.py | 10 |
1 files changed, 5 insertions, 5 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( |
@@ -229,7 +229,7 @@ async def main() -> None: | |||
229 | app=starlette_app, | 229 | app=starlette_app, |
230 | port=BOT_PORT, | 230 | port=BOT_PORT, |
231 | use_colors=False, | 231 | use_colors=False, |
232 | host="100.93.242.2", | 232 | host="0.0.0.0", |
233 | ) | 233 | ) |
234 | ) | 234 | ) |
235 | 235 | ||