aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-02-12 15:23:02 +0000
committerGravatar jesopo2019-02-12 15:23:02 +0000
commit7e4c1cadb1ae0f9a2e4dd48643dcaf8a179467cc (patch)
tree4e84dfb63d073afb9d5238b81c8670e71b904623
parentOnly put a ":" on trailing args when it's required (diff)
signature
Add !cointoss to random_number.py
-rw-r--r--modules/random_number.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/random_number.py b/modules/random_number.py
index 6fec2b25..51acb5a0 100644
--- a/modules/random_number.py
+++ b/modules/random_number.py
@@ -1,6 +1,8 @@
import random, uuid
from src import ModuleManager, utils
+COIN_SIDES = ["heads", "tails"]
+
class Module(ModuleManager.BaseModule):
_name = "Random"
@@ -29,6 +31,12 @@ class Module(ModuleManager.BaseModule):
event["stderr"].write(
"Both start and end must be valid integers")
+ @utils.hook("received.command.cointoss")
+ def coin_toss(self, event):
+ chosen_side = random.SystemRandom().choice(COIN_SIDES)
+ event["stdout"].write("%s tosses a coin and gets %s" %
+ (event["user"].nickname, chosen_side))
+
@utils.hook("received.command.uuid")
def uuid(self, event):
"""