butterrobot/butterrobot_plugins_contrib/fun.py

35 lines
932 B
Python
Raw Normal View History

2020-11-04 12:25:31 +00:00
import random
2020-09-17 18:16:42 +00:00
import dice
2020-04-22 21:58:06 +00:00
from butterrobot.plugins import Plugin
from butterrobot.objects import Message
class LoquitoPlugin(Plugin):
id = "contrib/fun/loquito"
@classmethod
2020-10-28 10:19:30 +00:00
def on_message(cls, message):
2020-04-22 21:58:06 +00:00
if "lo quito" in message.text.lower():
2020-09-17 14:09:31 +00:00
yield Message(chat=message.chat, reply_to=message.id, text="Loquito tu.",)
2020-09-17 18:16:42 +00:00
class DicePlugin(Plugin):
id = "contrib/fun/dice"
@classmethod
2020-10-28 10:19:30 +00:00
def on_message(cls, message: Message):
2020-09-17 18:16:42 +00:00
if message.text.startswith("!dice"):
roll = int(dice.roll(message.text.replace("!dice ", "")))
2020-11-04 12:25:31 +00:00
yield Message(chat=message.chat, reply_to=message.id, text=roll)
class CoinPlugin(Plugin):
id = "contrib/fun/coin"
@classmethod
def on_message(cls, message: Message):
if message.text.startswith("!coin"):
yield Message(chat=message.chat, reply_to=message.id, text=random.choice(("heads", "tails")))