Add !cointoss to random_number.py
This commit is contained in:
parent
86bc49a0a1
commit
7e4c1cadb1
1 changed files with 8 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
import random, uuid
|
import random, uuid
|
||||||
from src import ModuleManager, utils
|
from src import ModuleManager, utils
|
||||||
|
|
||||||
|
COIN_SIDES = ["heads", "tails"]
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
_name = "Random"
|
_name = "Random"
|
||||||
|
|
||||||
|
@ -29,6 +31,12 @@ class Module(ModuleManager.BaseModule):
|
||||||
event["stderr"].write(
|
event["stderr"].write(
|
||||||
"Both start and end must be valid integers")
|
"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")
|
@utils.hook("received.command.uuid")
|
||||||
def uuid(self, event):
|
def uuid(self, event):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue