Add !cointoss to random_number.py

This commit is contained in:
jesopo 2019-02-12 15:23:02 +00:00
parent 86bc49a0a1
commit 7e4c1cadb1

View file

@ -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):
"""