Update hello world example and add config example
This commit is contained in:
parent
400c9aaebc
commit
ac69c50b80
8 changed files with 49 additions and 10 deletions
25
examples/config/configurablebot.py
Normal file
25
examples/config/configurablebot.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
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("message")
|
||||
|
||||
|
||||
class DatabaseBot(Plugin):
|
||||
async def start(self) -> None:
|
||||
await super().start()
|
||||
self.config.load_and_update()
|
||||
|
||||
@classmethod
|
||||
def get_config_class(cls) -> Type[BaseProxyConfig]:
|
||||
return Config
|
||||
|
||||
@command.new("getmessage")
|
||||
async def handler(self, event: MessageEvent) -> None:
|
||||
if event.sender != self.client.mxid:
|
||||
await event.reply(self.config["message"])
|
Loading…
Add table
Add a link
Reference in a new issue