summaryrefslogtreecommitdiffstats
path: root/kalauerbot/bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'kalauerbot/bot.py')
-rw-r--r--kalauerbot/bot.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/kalauerbot/bot.py b/kalauerbot/bot.py
index 16dded0..2f75e5a 100644
--- a/kalauerbot/bot.py
+++ b/kalauerbot/bot.py
@@ -2,6 +2,7 @@ from matrixbot import MatrixBot
from functools import partial
import random
import json
+import os
import logging
from googletrans import LANGUAGES,Translator
logging.basicConfig(level=logging.DEBUG)
@@ -10,6 +11,8 @@ version = "1.0.0"
class Kalauerbot(MatrixBot):
def __init__(self,host,display_name,token,user_id,dbpath = "kalauerdb.json",allowlist=None):
+ log.debug(f"dbpath: {dbpath}")
+ log.debug(f"allowlist: {allowlist}")
self.allowlist = allowlist
self.dbpath=dbpath
self.load_db()
@@ -61,7 +64,7 @@ class Kalauerbot(MatrixBot):
!activate <name> - re-activate person
!kill - ultimately remove person from kalauer roster (cannot be reversed)
!choose - choose the next person to be the kalauer könig
- !who - find out who was chosen to be todays kalauer könig (alias: !wer)
+ !who - find out who was chosen to be todays kalauer könig (alias: !wer, !current)
!ok - confirm the kalauer (alias: !gut !passt !reicht !approved)
!reject - reject the kalauer (alias: !zu-gut !zu-schlecht !französisch !french)
!demand <name> - demand a certain person to be the new kalauer könig
@@ -106,7 +109,7 @@ class Kalauerbot(MatrixBot):
say(f"{chosen} was chosen to be the next kalauer könig, congratulations!")
self.save_db()
- elif command in ["!who","!wer"]:
+ elif command in ["!who","!wer", "!current"]:
if chosen:
say(f"{chosen} was chosen to be the next kalauer könig")
else:
@@ -136,7 +139,7 @@ class Kalauerbot(MatrixBot):
name = args.strip()
if name in self.active_db():
say(f"The previous kalauer könig demands user {name} to be the next kalauer könig. The rules of the Kalauer are divine and shall be respected.")
- db["__choses__"] = name
+ db["__chosen__"] = name
elif name in db:
say(f"{name} is currently not active, cannot be chosen")
else:
@@ -171,11 +174,16 @@ class Kalauerbot(MatrixBot):
log.debug(f"Receive message {msg}")
def main():
+ allowlist = os.environ.get("KALAUER_ALLOWLIST",None)
+ if allowlist:
+ allowlist = allowlist.split(',')
bot = Kalauerbot(
host = "ext01.citadel.team",
display_name = "Kalauerbot",
token = os.environ['CITADEL_TOKEN'],
user_id = os.environ["CITADEL_ID"],
+ dbpath = os.environ.get("KALAUER_DBPATH",None) or "kalauerdb.json",
+ allowlist = allowlist
)
bot.start()