mirror of
https://github.com/maubot/maubot.git
synced 2024-09-21 00:05:43 +00:00
Compare commits
8 Commits
b11e15117e
...
c6e7a302ae
Author | SHA1 | Date | |
---|---|---|---|
|
c6e7a302ae | ||
|
91f214819a | ||
|
299d8f68c3 | ||
|
a7f31f6175 | ||
|
4f68e20ff7 | ||
|
7759643e93 | ||
|
2c60342cc6 | ||
|
f63be9059b |
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,6 +13,7 @@ __pycache__
|
|||||||
!example-config.yaml
|
!example-config.yaml
|
||||||
!.pre-commit-config.yaml
|
!.pre-commit-config.yaml
|
||||||
|
|
||||||
|
/start
|
||||||
logs/
|
logs/
|
||||||
plugins/
|
plugins/
|
||||||
trash/
|
trash/
|
||||||
|
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,3 +1,21 @@
|
|||||||
|
# v0.5.0 (unreleased)
|
||||||
|
|
||||||
|
* Fixed `main_class` to default to being loaded from the last module instead of
|
||||||
|
the first if a module name is not explicitly specified.
|
||||||
|
* This was already the [documented behavior](https://docs.mau.fi/maubot/dev/reference/plugin-metadata.html),
|
||||||
|
and loading from the first module doesn't make sense due to import order.
|
||||||
|
* Added simple scheduler utility for running background tasks periodically or
|
||||||
|
after a certain delay.
|
||||||
|
* Added testing framework for plugins (thanks to [@abompard] in [#225]).
|
||||||
|
* Changed `mbc build` to ignore directories declared in `modules` that are
|
||||||
|
missing an `__init__.py` file.
|
||||||
|
* Importing the modules at runtime would fail and break the plugin.
|
||||||
|
To include non-code resources outside modules in the mbp archive,
|
||||||
|
use `extra_files` instead.
|
||||||
|
|
||||||
|
[#225]: https://github.com/maubot/maubot/issues/225
|
||||||
|
[@abompard]: https://github.com/abompard
|
||||||
|
|
||||||
# v0.4.2 (2023-09-20)
|
# v0.4.2 (2023-09-20)
|
||||||
|
|
||||||
* Updated Pillow to 10.0.1.
|
* Updated Pillow to 10.0.1.
|
||||||
|
@ -22,7 +22,7 @@ All setup and usage instructions are located on
|
|||||||
Matrix room: [#maubot:maunium.net](https://matrix.to/#/#maubot:maunium.net)
|
Matrix room: [#maubot:maunium.net](https://matrix.to/#/#maubot:maunium.net)
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
A list of plugins can be found at [plugins.maubot.xyz](https://plugins.maubot.xyz/).
|
A list of plugins can be found at [plugins.mau.bot](https://plugins.mau.bot/).
|
||||||
|
|
||||||
To add your plugin to the list, send a pull request to <https://github.com/maubot/plugins.maubot.xyz>.
|
To add your plugin to the list, send a pull request to <https://github.com/maubot/plugins.maubot.xyz>.
|
||||||
|
|
||||||
|
@ -93,10 +93,16 @@ def write_plugin(meta: PluginMeta, output: str | IO) -> None:
|
|||||||
if os.path.isfile(f"{module}.py"):
|
if os.path.isfile(f"{module}.py"):
|
||||||
zip.write(f"{module}.py")
|
zip.write(f"{module}.py")
|
||||||
elif module is not None and os.path.isdir(module):
|
elif module is not None and os.path.isdir(module):
|
||||||
zipdir(zip, module)
|
if os.path.isfile(f"{module}/__init__.py"):
|
||||||
|
zipdir(zip, module)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
Fore.YELLOW
|
||||||
|
+ f"Module {module} is missing __init__.py, skipping"
|
||||||
|
+ Fore.RESET
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
print(Fore.YELLOW + f"Module {module} not found, skipping" + Fore.RESET)
|
print(Fore.YELLOW + f"Module {module} not found, skipping" + Fore.RESET)
|
||||||
|
|
||||||
for pattern in meta.extra_files:
|
for pattern in meta.extra_files:
|
||||||
for file in glob.iglob(pattern):
|
for file in glob.iglob(pattern):
|
||||||
zip.write(file)
|
zip.write(file)
|
||||||
|
@ -167,7 +167,7 @@ class ZippedPluginLoader(PluginLoader):
|
|||||||
if "/" in meta.main_class:
|
if "/" in meta.main_class:
|
||||||
self.main_module, self.main_class = meta.main_class.split("/")[:2]
|
self.main_module, self.main_class = meta.main_class.split("/")[:2]
|
||||||
else:
|
else:
|
||||||
self.main_module = meta.modules[0]
|
self.main_module = meta.modules[-1]
|
||||||
self.main_class = meta.main_class
|
self.main_class = meta.main_class
|
||||||
self._file = file
|
self._file = file
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ from mautrix.types import (
|
|||||||
RelatesTo,
|
RelatesTo,
|
||||||
RoomID,
|
RoomID,
|
||||||
TextMessageEventContent,
|
TextMessageEventContent,
|
||||||
|
EventContext,
|
||||||
|
RoomEventFilter,
|
||||||
)
|
)
|
||||||
from mautrix.util import markdown
|
from mautrix.util import markdown
|
||||||
from mautrix.util.formatter import EntityType, MarkdownString, MatrixParser
|
from mautrix.util.formatter import EntityType, MarkdownString, MatrixParser
|
||||||
@ -278,7 +280,19 @@ class MaubotMatrixClient(MatrixClient):
|
|||||||
return super().dispatch_event(event, source)
|
return super().dispatch_event(event, source)
|
||||||
|
|
||||||
async def get_event(self, room_id: RoomID, event_id: EventID) -> Event:
|
async def get_event(self, room_id: RoomID, event_id: EventID) -> Event:
|
||||||
evt = await super().get_event(room_id, event_id)
|
return await self._decrypt_event(await super().get_event(room_id, event_id))
|
||||||
|
|
||||||
|
async def get_event_context(self, room_id: RoomID, event_id: EventID, limit: int | None = 10,
|
||||||
|
filter: RoomEventFilter | None = None) -> EventContext:
|
||||||
|
event_context = await super().get_event_context(room_id=room_id,event_id=event_id,
|
||||||
|
limit=limit,filter=filter)
|
||||||
|
event_context.events_after = [await self._decrypt_event(evt)
|
||||||
|
for evt in event_context.events_after]
|
||||||
|
event_context.events_before = [await self._decrypt_event(evt)
|
||||||
|
for evt in event_context.events_before]
|
||||||
|
return event_context
|
||||||
|
|
||||||
|
async def _decrypt_event(self, evt: Event):
|
||||||
if isinstance(evt, EncryptedEvent) and self.crypto:
|
if isinstance(evt, EncryptedEvent) and self.crypto:
|
||||||
try:
|
try:
|
||||||
self.crypto_log.trace(f"get_event: Decrypting {evt.event_id} in {evt.room_id}...")
|
self.crypto_log.trace(f"get_event: Decrypting {evt.event_id} in {evt.room_id}...")
|
||||||
|
@ -115,7 +115,7 @@ with open(args.meta, "r") as meta_file:
|
|||||||
if "/" in meta.main_class:
|
if "/" in meta.main_class:
|
||||||
module, main_class = meta.main_class.split("/", 1)
|
module, main_class = meta.main_class.split("/", 1)
|
||||||
else:
|
else:
|
||||||
module = meta.modules[0]
|
module = meta.modules[-1]
|
||||||
main_class = meta.main_class
|
main_class = meta.main_class
|
||||||
|
|
||||||
if args.meta != "maubot.yaml" and os.path.dirname(args.meta) != "":
|
if args.meta != "maubot.yaml" and os.path.dirname(args.meta) != "":
|
||||||
|
Loading…
Reference in New Issue
Block a user