36 lines
749 B
Python
36 lines
749 B
Python
from typing import Dict
|
|
import re
|
|
import numpy as np
|
|
from dice.dice import Dice
|
|
|
|
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]
|
|
params = kwargs['message'].replace(c, '')
|
|
|
|
if c in commands:
|
|
commands[c](kwargs, params)
|
|
else:
|
|
error_response(kwargs, params)
|
|
|
|
|
|
@command('/roll')
|
|
def custom_roll(kwargs, params):
|
|
print(f'Kwargs: {kwargs}. Params: {params}')
|
|
dice = Dice()
|
|
print(dice.roll(params))
|
|
|
|
|
|
def error_response(kwargs, params):
|
|
print(f'Error, received unknown command: {kwargs}')
|