diff --git a/.buildpacks b/.buildpacks deleted file mode 100644 index 0e75675..0000000 --- a/.buildpacks +++ /dev/null @@ -1,2 +0,0 @@ -https://github.com/moneymeets/python-poetry-buildpack.git -https://github.com/heroku/heroku-buildpack-python.git diff --git a/Procfile b/Procfile deleted file mode 100644 index 827e04a..0000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -app: python run.py \ No newline at end of file diff --git a/config/local.example.json b/config/local.example.json deleted file mode 100644 index 152fb2b..0000000 --- a/config/local.example.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "discord_token": "discord_bot_token" -} \ No newline at end of file diff --git a/config/production.example.json b/config/production.example.json deleted file mode 100644 index 08d4c4b..0000000 --- a/config/production.example.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "discord_token_env_var": "DISCORD_TOKEN", - "redis_url_env_var": "REDISCLOUD_URL" -} \ No newline at end of file diff --git a/config/production.json b/config/production.json deleted file mode 100644 index 04c489a..0000000 --- a/config/production.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "discord_token_env_var": "DISCORD_TOKEN", - "redis_url_env_var": "REDIS_URL" -} \ No newline at end of file diff --git a/run.py b/run.py deleted file mode 100644 index 7933e3b..0000000 --- a/run.py +++ /dev/null @@ -1,18 +0,0 @@ -import logging -import sys -from pathlib import Path - -sys.path.insert(0, str((Path(__file__).parent / 'src').resolve())) - -from rollbot.bot import bot -from rollbot.config import Config - - -config = Config("config/production.json") - -logging.basicConfig( - level=logging.INFO, - format="[%(levelname)s] %(asctime)s - %(message)s", -) - -bot.run(config.token) diff --git a/runlocal.py b/runlocal.py deleted file mode 100644 index 763fe9d..0000000 --- a/runlocal.py +++ /dev/null @@ -1,18 +0,0 @@ -import os -import sys -import logging -sys.path.insert(0, os.getcwd()) - -from rollbot.bot import bot -from rollbot.config import Config - - -config = Config("config/local.json") - -logging.basicConfig( - level=logging.WARNING, - format="%(asctime)s,%(msecs)d %(levelname)s: %(message)s", - datefmt="%H:%M:%S", -) - -bot.run(config.token) diff --git a/src/rollbot/plottenbakker/distributer.py b/src/rollbot/plottenbakker/distributer.py new file mode 100644 index 0000000..239b52e --- /dev/null +++ b/src/rollbot/plottenbakker/distributer.py @@ -0,0 +1,36 @@ +import sys +from datetime import timedelta +from rollbot.interpreter.calculator import distribute, EvaluationError +from rollbot.varenv import VarEnv +from lark.exceptions import UnexpectedInput + + +if __name__ == "__main__": + varenv_name = sys.stdin.readline().strip() + expression = sys.stdin.readline().strip() + + try: + env = VarEnv(varenv_name) + except: + print("No such environment") + sys.exit(1) + + try: + data = distribute(expression, timedelta(seconds=5), env) + if not data: + print(f"Unprocessable input") + sys.exit(1) + xbins, data, num_rolls = data + except EvaluationError as e: + print(e.args[0]) + sys.exit(1) + except UnexpectedInput as e: + print(f"Unexpected input: ```\n{e.get_context(expression)}```") + sys.exit(1) + except: + print("Server error") + sys.exit(1) + + print(" ".join(str(x) for x in xbins)) + print(" ".join(str(x) for x in data)) + print(num_rolls) \ No newline at end of file