aboutsummaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-24 00:51:04 -0800
committerclarkzjw <[email protected]>2023-02-24 00:51:04 -0800
commit4bb5cbdc16ecf5f6e5961373816d4c741d54ee51 (patch)
treeea85f216881bacb54f579cae9814e2f85aa1abe5 /bot.py
parenta9fb6f252553ae49a2ba372434073824babe31e4 (diff)
parent391abe42adf3bf065d9543ada068b696b00efdcd (diff)
downloadswarm2fediverse-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.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bot.py b/bot.py
index 1d59f9e..bcfab8f 100644
--- a/bot.py
+++ b/bot.py
@@ -8,7 +8,7 @@ from config import BOT_TOKEN, TELEGRAM_WEBHOOK_URL, HEALTHCHECK_URL, FEDI_LOGIN_
8import uvicorn 8import uvicorn
9from starlette.applications import Starlette 9from starlette.applications import Starlette
10from starlette.requests import Request 10from starlette.requests import Request
11from starlette.responses import PlainTextResponse, Response 11from starlette.responses import PlainTextResponse, Response, JSONResponse
12from starlette.routing import Route 12from starlette.routing import Route
13from telegram import Update 13from telegram import Update
14from telegram.ext import ( 14from 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
Powered by cgit v1.2.3 (git 2.41.0)