Added admin interface to manage channels and enabled plugins (#9)
* Added base admin login/logout flows * Ignore local database * Channel model * Admin interface for channels and plugins * Added database tests along with workflows * Added some docstrings * Ignore .coverage file * Creating plugins docs WIP * Documentation * Black everything * Some documentation * Coverage for the plugins package as well * DB Fixes * Absolute FROM in Dockerfile * Database and logging fixes * Slack: Support private channels * Added pre-commit * black'd * Fixed UserQuery.create * Fixed ChannelPluginQuery.create exists call * Added ChannelPlugin menu for debugging * Ignore sqlite databases * Updated contributing docs
This commit is contained in:
parent
456d144a7d
commit
57b413dd1b
45 changed files with 2210 additions and 421 deletions
|
@ -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
|
||||
|
|
|
@ -1,34 +1,51 @@
|
|||
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.",)
|
||||
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")))
|
||||
yield Message(
|
||||
chat=message.chat,
|
||||
reply_to=message.id,
|
||||
text=random.choice(("heads", "tails")),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue