Trivia command

This commit is contained in:
NikolajDanger
2020-04-05 18:37:59 +02:00
parent 906ff4361a
commit 1e2f64c67c
7 changed files with 162 additions and 26 deletions

1
funcs/roll/__init__.py Normal file
View File

@ -0,0 +1 @@
from .dice import roll_dice

View File

@ -18,6 +18,23 @@ DICE_PATTERN = re.compile(
IGNORECASE)
def roll_dice(author : str, rollStr : str = "1d20"):
if rollStr == '0/0': # easter eggs
return("What do you expect me to do, destroy the universe?")
adv = 0
if re.search('(^|\s+)(adv|dis)(\s+|$)', rollStr) is not None:
adv = 1 if re.search('(^|\s+)adv(\s+|$)', rollStr) is not None else -1
rollStr = re.sub('(adv|dis)(\s+|$)', '', rollStr)
res = roll(rollStr, adv=adv)
out = res.result
outStr = author + ' :game_die:\n' + out
if len(outStr) > 1999:
outputs = author + ' :game_die:\n[Output truncated due to length]\n**Result:** ' + str(res.plain)
else:
outputs = outStr
return(outputs)
def list_get(index, default, l):
try:
a = l[index]