diff --git a/example-maubot.ini b/example-maubot.ini new file mode 100644 index 0000000..f5ffb5a --- /dev/null +++ b/example-maubot.ini @@ -0,0 +1,16 @@ +# This is an example maubot plugin definition file. +# All plugins must include a file like this named "maubot.ini" in their root directory. +[maubot] +# The unique ID for the plugin. Java package naming style. +ID = xyz.maubot.plugin +# A PEP 440 compliant version string. +Version = 1.0.0 +# The comma-separated list of modules to load from the plugin archive. +# Submodules that are imported by modules listed here don't need to be listed separately. +# However, top-level modules must always be listed even if they're imported by other modules. +Modules = plugin +# The main class of the plugin. Format: module/Class +# If `module` is omitted, will default to last module specified in the module list. +# Even if `module` is not omitted here, it must be included in the modules list. +# The main class must extend maubot.Plugin +MainClass = PluginClass diff --git a/maubot/client.py b/maubot/client.py index 80b947a..0861390 100644 --- a/maubot/client.py +++ b/maubot/client.py @@ -18,7 +18,8 @@ from aiohttp import ClientSession import asyncio import logging -from mautrix.types import UserID, SyncToken, FilterID, ContentURI, StateEvent, Membership, EventType +from mautrix.types import (UserID, SyncToken, FilterID, ContentURI, StrippedStateEvent, Membership, + EventType) from .db import DBClient from .matrix import MaubotMatrixClient @@ -49,9 +50,13 @@ class Client: async def _start(self) -> None: try: + if self.displayname != "disable": + await self.client.set_displayname(self.displayname) + if self.avatar_url != "disable": + await self.client.set_avatar_url(self.avatar_url) await self.client.start() except Exception: - self.log.exception("Fail") + self.log.exception("starting raised exception") def stop(self) -> None: self.client.stop() @@ -70,7 +75,7 @@ class Client: def all(cls) -> List['Client']: return [cls.get(user.id, user) for user in DBClient.query.all()] - async def _handle_invite(self, evt: StateEvent) -> None: + async def _handle_invite(self, evt: StrippedStateEvent) -> None: if evt.state_key == self.id and evt.content.membership == Membership.INVITE: await self.client.join_room_by_id(evt.room_id)