Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Byte-compiled
__pycache__/
*.py[cod]
*$py.class

# Virtual environment
.venv/
venv/
env/

# Environment variables
.env
.env.*

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Project: session & data files
*.session
*.session-journal
*.session-backup
*.txt
mxu.rocksdb/

# Docker
docker-compose.override.yml
src/mxuserbot/community
# Logs
*.log

# uv
uv.lock
13 changes: 8 additions & 5 deletions src/mxuserbot/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,14 @@ async def _internal_init(self, name, db, loader_or_dict, is_core: bool):
self.friendly_name = self.strings.get("name") or self.config.get("name") or self.__class__.__name__

schema = getattr(self.__class__, "config", {})
self.config = ModuleConfig(
self._get,
self._set,
schema
)
if is_core:
async def _cfg_get(key: str, default=None):
return await db.get(name, key, default)
async def _cfg_set(key: str, value):
return await db.set(name, key, value)
self.config = ModuleConfig(_cfg_get, _cfg_set, schema)
else:
self.config = ModuleConfig(self._get, self._set, schema)
await self.config._load_from_db()

self._commands = {}
Expand Down
14 changes: 9 additions & 5 deletions src/mxuserbot/modules/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Meta:
name = "HelperModule"
description = "helper Centre"
version = "2.2.0"
version = "2.3.0"
dependencies = ["patchlib"]
tags = ["helper"]

Expand Down Expand Up @@ -243,6 +243,13 @@ class Strings(BaseModel):
class HelperModule(loader.Module):
strings = locales

config = {
"banner_url": loader.ConfigValue(
default="mxc://matrix.org/YiqPIkdkkiJqMqizxJQTBqVx",
description="Banner image URL for .info command",
),
}

def _module_name(self, mod) -> str:
return getattr(getattr(mod, "Meta", None), "name", mod.__class__.__name__)

Expand Down Expand Up @@ -403,17 +410,14 @@ async def on_page(ctx: utils.EmojiCallbackContext) -> None:
@loader.command()
async def info(self, mx, event: MessageEvent):
"""System information card"""
banner_url = await mx._get_core_conf("banner_url") or "mxc://matrix.org/YiqPIkdkkiJqMqizxJQTBqVx"
await utils.answer(
mx,
room_id=event.room_id,
media=Image(
url=banner_url,
url=self.config["banner_url"],
caption=self.strings["info_caption"].format(version=mx.version),
filename="info.png",
mimetype="image/png",
w=600,
h=335,
),
)

Expand Down