Skip to content

Commit

Permalink
Add new alias and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sheiun committed Oct 24, 2020
1 parent 87ebfa3 commit 999eb0b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plurk_dice/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dice20": 20,
"draw": "lots",
"lot": "lots",
"bz": "bzz",
"bzzz": "bzz",
}
DICE = {
Expand Down Expand Up @@ -141,6 +142,15 @@ def roll(self, base64=False) -> Dict[str, Union[str, int]]:

@classmethod
def parse(cls, text: str, **kwargs) -> List[Dict[str, Union[str, int]]]:
"""Parse text like usage in Plurk.
Args:
text (str): Text input
kwargs: passed into `cls.roll()`
Returns:
List[Dict[str, Union[str, int]]]: All results from parsed dices.
"""
results = re.findall(r"\((.*?)\)", text)
return [cls(DICE_ALIAS.get(r, r)).roll(**kwargs) for r in results]

Expand Down

0 comments on commit 999eb0b

Please sign in to comment.