From 6413ce746978cac7ed666f455a57680b299dc7f2 Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 15 Aug 2020 14:26:57 +0200 Subject: init setup.py --- kalauerbot/bot.py | 14 +++++++++++--- setup.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 setup.py 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 - 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 - 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() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b090ad7 --- /dev/null +++ b/setup.py @@ -0,0 +1,28 @@ +from setuptools import setup + +setup( + name="kalauerbot", + description="Bot for managing the Kalauer König", + version="1.0.0", + packages=["kalauerbot"], + license="MIT", + long_description=open("README.md").read(), + author="Felix Richter", + author_email="github@krebsco.de", + install_requires=[ + "python-matrixbot", + "googletrans", + ], + entry_points={"console_scripts": [ + "kalauerbot = kalauerbot.bot:main" + ]}, + classifiers=[ + "Intended Audience :: Human", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "Development Status :: 3 - Alpha", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: Implementation :: CPython", + ], +) -- cgit v1.2.3