Skip to content
This repository was archived by the owner on Oct 23, 2019. It is now read-only.

Commit 580dff2

Browse files
committed
Updated format strings to remove ' literals and added invalid roll const
As per request the format strings utilizing a single quote within the string have been modified to remove the quotes and use the {!r} formatter. The string for invalid rolls has also been moved to a constant for consistency with the rest of the plugin as well as improving readability.
1 parent bcba983 commit 580dff2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

plugins/gaming.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
from cloudbot import hook
1818

1919
# String constants for the coin flip function
20-
INVALID_NUMBER = "Invalid input '{}': not a number"
20+
INVALID_NUMBER = "Invalid input {!r}: not a number"
2121
NO_COIN = "makes a coin flipping motion"
2222
SINGLE_COIN = "flips a coin and gets {}."
2323
MANY_COINS = "flips {} coins and gets {} heads and {} tails."
2424

25+
INVALID_ROLL = "Invalid dice roll {!r}"
26+
2527
ROLL_LIMIT = 100 # The maximum number of times to roll or flip before approximating results
2628

2729
whitespace_re = re.compile(r'\s+')
@@ -64,15 +66,15 @@ def dice(text, notice):
6466
if match:
6567
text, desc = match.groups()
6668
else:
67-
notice("Invalid dice roll '{}'".format(text))
69+
notice(INVALID_ROLL.format(text))
6870
return
6971

7072
if "d" not in text:
7173
return
7274

7375
spec = whitespace_re.sub('', text)
7476
if not valid_diceroll.match(spec):
75-
notice("Invalid dice roll '{}'".format(text))
77+
notice(INVALID_ROLL.format(text))
7678
return
7779
groups = sign_re.findall(spec)
7880

0 commit comments

Comments
 (0)