mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Set bot profile info at startup and add example maubot.ini
This commit is contained in:
parent
350749a2c1
commit
4d2f2cd173
16
example-maubot.ini
Normal file
16
example-maubot.ini
Normal file
@ -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
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user