""" This plugin provides a command to list all loaded plugins along with their descriptions. """ # plugins/plugins.py import os import sys import logging import simplematrixbotlib as botlib async def handle_command(room, message, bot, prefix, config): match = botlib.MessageMatch(room, message, bot, prefix) if match.is_not_from_this_bot() and match.prefix() and match.command("plugins"): logging.info("Received !plugins command") plugin_descriptions = get_plugin_descriptions() plugin_descriptions.insert(0, "
🔌Plugins List🔌
⤵︎Click Here to Expand⤵︎
") plugins_message = "
".join(plugin_descriptions) plugins_message += "
" await bot.api.send_markdown_message(room.room_id, plugins_message) logging.info("Sent plugin list to the room") def get_plugin_descriptions(): plugin_descriptions = [] for module_name, module in sys.modules.items(): if module_name.startswith("plugins.") and hasattr(module, "__file__"): plugin_path = module.__file__ plugin_name = os.path.basename(plugin_path).split(".")[0] if hasattr(module, "__description__"): description = module.__description__ elif module.__doc__: description = module.__doc__.strip().split("\n")[0] else: description = "No description available" plugin_descriptions.append(f"[{plugin_name}.py]: {description}") plugin_descriptions.sort() return plugin_descriptions # --------------------------------------------------------------------------- # Plugin Metadata # --------------------------------------------------------------------------- __version__ = "1.0.0" __author__ = "Funguy Bot" __description__ = "List all loaded plugins" __help__ = """
!plugins – List loaded plugins

Displays all currently loaded plugins and their descriptions.

"""