32 lines
572 B
Python
32 lines
572 B
Python
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]
|
|
|
|
if c in commands:
|
|
commands[c](kwargs)
|
|
else:
|
|
error_response(kwargs)
|
|
|
|
|
|
@command('/roll')
|
|
def custom_roll(kwargs):
|
|
print(f'/roll received {kwargs}')
|
|
|
|
|
|
def error_response(kwargs):
|
|
print(f'Error, received unknown command: {kwargs}')
|