BLACKDIAMONT
Lt. Commander
- Registriert
- Nov. 2012
- Beiträge
- 1.475
Moinsen,
ich bastel an Matrix (riot.im) und habe natürlich auch bots entdeckt .... leider ist alles in python und wirklich Beispiele ausser "hello world" gibts dafür nicht ....
Code abschauen usw hilft zwar manchmal aber aktuell steh ich vor Problemen^^
Hoffe ihr könnt mir evtl unter die Arme greifen, ohne das ich jetz Tage mit python lernen für nen mini-Plugin verbringen muss ..
Abschauen tu ich hier
Was ich gebastelt habe:
Das auskommentierte commands (nur mit der CommandsReplyBot class) funktioniert einwandfrei, allerdings will ich diese über die config dynamisch anpassen (geht über das Bot Webinterface via base-config.yaml).
Ich habe soweit alles hinzugefügt wo ich denke, das es reingehört
Fehlermeldung ist -> TypeError: 'NoneType' object is not subscriptable
Jep ..... Bahnhof für mich trotz google :/
Wer kann helfen?
ich bastel an Matrix (riot.im) und habe natürlich auch bots entdeckt .... leider ist alles in python und wirklich Beispiele ausser "hello world" gibts dafür nicht ....
Code abschauen usw hilft zwar manchmal aber aktuell steh ich vor Problemen^^
Hoffe ihr könnt mir evtl unter die Arme greifen, ohne das ich jetz Tage mit python lernen für nen mini-Plugin verbringen muss ..
Abschauen tu ich hier
Was ich gebastelt habe:
Python:
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
from maubot import Plugin, MessageEvent
from maubot.handlers import command
from typing import List, Tuple
import re
class Config(BaseProxyConfig):
def do_update(self, helper: ConfigUpdateHelper) -> None:
helper.copy("commands")
@classmethod
def get_config_class(cls) -> Type[BaseProxyConfig]:
return Config
async def start(self) -> None:
self.on_external_config_update()
def on_external_config_update(self) -> None:
self.config.load_and_update()
commands = self.config["commands"]
class CommandsReplyBot(Plugin):
@command.new("commands")
async def handler(self, event: MessageEvent) -> None:
commands = self.config["commands"]
#commands = "Maubot Commands:<br>!joke<br>!validation<br>!ud<br>!trump<br>!remind<br>!tmdb<br>!xkcd<br>!roll<br>!poll<br>!rss"
await event.reply(commands, allow_html=True)
Das auskommentierte commands (nur mit der CommandsReplyBot class) funktioniert einwandfrei, allerdings will ich diese über die config dynamisch anpassen (geht über das Bot Webinterface via base-config.yaml).
Ich habe soweit alles hinzugefügt wo ich denke, das es reingehört
Fehlermeldung ist -> TypeError: 'NoneType' object is not subscriptable
Jep ..... Bahnhof für mich trotz google :/
Wer kann helfen?