Add Cloudron packaging for Maubot
This commit is contained in:
27
maubot-src/examples/config/configurablebot.py
Normal file
27
maubot-src/examples/config/configurablebot.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import Type
|
||||
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
||||
from maubot import Plugin, MessageEvent
|
||||
from maubot.handlers import command
|
||||
|
||||
|
||||
class Config(BaseProxyConfig):
|
||||
def do_update(self, helper: ConfigUpdateHelper) -> None:
|
||||
helper.copy("whitelist")
|
||||
helper.copy("command_prefix")
|
||||
|
||||
|
||||
class ConfigurableBot(Plugin):
|
||||
async def start(self) -> None:
|
||||
self.config.load_and_update()
|
||||
|
||||
def get_command_name(self) -> str:
|
||||
return self.config["command_prefix"]
|
||||
|
||||
@command.new(name=get_command_name)
|
||||
async def hmm(self, evt: MessageEvent) -> None:
|
||||
if evt.sender in self.config["whitelist"]:
|
||||
await evt.reply("You're whitelisted 🎉")
|
||||
|
||||
@classmethod
|
||||
def get_config_class(cls) -> Type[BaseProxyConfig]:
|
||||
return Config
|
||||
Reference in New Issue
Block a user