added command and error handling. added comman /roll as a placeholder
This commit is contained in:
@@ -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
|
||||
}
|
||||
def error_response(kwargs):
|
||||
print(f'Error, received unknown command: {kwargs}')
|
||||
|
||||
Reference in New Issue
Block a user