|
@@ -3,6 +3,7 @@ import json
|
|
|
import traceback
|
|
|
import asyncio
|
|
|
import logging
|
|
|
+import os
|
|
|
|
|
|
import toml
|
|
|
from fastapi import FastAPI, BackgroundTasks, Response
|
|
@@ -13,9 +14,9 @@ from commands import config
|
|
|
|
|
|
logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
|
|
|
|
|
|
-with open("secrets.toml", "r") as sfile:
|
|
|
+with open(os.environ.get("SECRET_FILE", "secrets.toml"), "r") as sfile:
|
|
|
secrets = toml.load(sfile)
|
|
|
-database_file = secrets["database_file"]
|
|
|
+database_file = os.environ.get("DATABASE_FILE", secrets["database_file"])
|
|
|
groupme_bots = secrets["groupme_bots"]
|
|
|
groupme_token = secrets["groupme_token"]
|
|
|
groupme_admins = secrets["admins"]["origin"]
|
|
@@ -37,9 +38,7 @@ class GroupMeMessage(BaseModel):
|
|
|
|
|
|
class GroupMeBot(rollbot.Rollbot[GroupMeMessage]):
|
|
|
def __init__(self):
|
|
|
- super().__init__(
|
|
|
- config.extend(rollbot.CommandConfiguration(bangs=("!",))), database_file
|
|
|
- )
|
|
|
+ super().__init__(config.extend(rollbot.CommandConfiguration(bangs=("!",))), database_file)
|
|
|
|
|
|
def read_config(self, key):
|
|
|
cfg = secrets
|
|
@@ -147,3 +146,8 @@ async def shutdown():
|
|
|
async def receive(message: GroupMeMessage, tasks: BackgroundTasks):
|
|
|
tasks.add_task(bot.on_message, message)
|
|
|
return Response(status_code=204)
|
|
|
+
|
|
|
+
|
|
|
+@app.get("/health", status_code=204)
|
|
|
+def health():
|
|
|
+ return Response(status_code=204)
|