diff --git a/chatCommands.py b/chatCommands.py index 2b30fc6..4fd18c4 100644 --- a/chatCommands.py +++ b/chatCommands.py @@ -2,17 +2,30 @@ from typing import Dict import random +commands: Dict = {} + + +def command(*commandlist): + def add_command(function): + for command in commandlist: + commands[command] = function + return function + return add_command + def handle_command(kwargs): + c = kwargs['message'].split()[0] - command = kwargs['message'].split()[0] - print(command) + if c in commands: + commands[c](kwargs) + else: + error_response(kwargs) -def custom_roll(character, message): - print('asd') +@command('/roll') +def custom_roll(kwargs): + print(f'/roll received {kwargs}') -commands: Dict = { - '/roll': custom_roll -} \ No newline at end of file +def error_response(kwargs): + print(f'Error, received unknown command: {kwargs}')