Added !dice command

This commit is contained in:
Felipe M 2020-09-17 20:16:42 +02:00
parent 9921d067ff
commit 903076de54
Signed by: fmartingr
GPG key ID: 716BC147715E716F
4 changed files with 57 additions and 6 deletions

View file

@ -1,3 +1,5 @@
import dice
from butterrobot.plugins import Plugin
from butterrobot.objects import Message
@ -9,3 +11,13 @@ class LoquitoPlugin(Plugin):
async def on_message(cls, message):
if "lo quito" in message.text.lower():
yield Message(chat=message.chat, reply_to=message.id, text="Loquito tu.",)
class DicePlugin(Plugin):
id = "contrib/fun/dice"
@classmethod
async def on_message(cls, message: Message):
if message.text.startswith("!dice"):
roll = int(dice.roll(message.text.replace("!dice ", "")))
yield Message(chat=message.chat, reply_to=message.id, text=roll)