Admin interface for channels and plugins

This commit is contained in:
Felipe M 2020-12-08 20:17:19 +01:00
parent 78d943d530
commit b0e82fdefc
Signed by: fmartingr
GPG key ID: 716BC147715E716F
23 changed files with 859 additions and 169 deletions

View file

@ -5,10 +5,11 @@ from butterrobot.objects import Message
class PingPlugin(Plugin):
id = "contrib/dev/ping"
name = "Ping command"
id = "contrib.dev.ping"
@classmethod
def on_message(cls, message):
def on_message(cls, message, **kwargs):
if message.text == "!ping":
delta = datetime.now() - message.date
delta_ms = delta.seconds * 1000 + delta.microseconds / 1000

View file

@ -1,34 +1,45 @@
import random
import dice
import structlog
from butterrobot.plugins import Plugin
from butterrobot.objects import Message
logger = structlog.get_logger(__name__)
class LoquitoPlugin(Plugin):
id = "contrib/fun/loquito"
name = "Loquito reply"
id = "contrib.fun.loquito"
@classmethod
def on_message(cls, message):
def on_message(cls, message, **kwargs):
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"
name = "Dice command"
id = "contrib.fun.dice"
DEFAULT_FORMULA = "1d20"
@classmethod
def on_message(cls, message: Message):
def on_message(cls, message: Message, **kwargs):
if message.text.startswith("!dice"):
roll = int(dice.roll(message.text.replace("!dice ", "")))
dice_formula = message.text.replace("!dice", "").strip()
if not dice_formula:
dice_formula = cls.DEFAULT_FORMULA
roll = int(dice.roll(dice_formula))
yield Message(chat=message.chat, reply_to=message.id, text=roll)
class CoinPlugin(Plugin):
id = "contrib/fun/coin"
name = "Coin command"
id = "contrib.fun.coin"
@classmethod
def on_message(cls, message: Message):
def on_message(cls, message: Message, **kwargs):
if message.text.startswith("!coin"):
yield Message(chat=message.chat, reply_to=message.id, text=random.choice(("heads", "tails")))