quote plugin added. Fixed funguy.py and plugins.py for plugin list.

This commit is contained in:
2026-05-07 22:43:21 -05:00
parent c263b2c40e
commit a4f3725354
4 changed files with 236 additions and 72 deletions
+33 -31
View File
@@ -1,11 +1,8 @@
"""
This plugin provides a command to list all loaded plugins along with their descriptions.
This plugin lists all loaded plugins (from bot.plugins) inside a collapsible block,
and sends a separate alwaysvisible line showing the total active count.
"""
# plugins/plugins.py
import os
import sys
import logging
import simplematrixbotlib as botlib
@@ -13,46 +10,51 @@ 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, "<details><summary><strong>🔌Plugins List🔌<br>⤵︎Click Here to Expand⤵︎</strong></summary>")
plugins_message = "<br>".join(plugin_descriptions)
plugins_message += "</details>"
# Fetch the real, currently loaded plugins from the bot instance
plugins_dict = getattr(bot, "plugins", {})
if not plugins_dict:
await bot.api.send_markdown_message(room.room_id, "📊 **Total Active Plugins:** 0")
return
await bot.api.send_markdown_message(room.room_id, plugins_message)
logging.info("Sent plugin list to the room")
# Build sorted list of descriptions
plugin_items = []
for plugin_name, module in sorted(plugins_dict.items()):
desc = getattr(module, "__description__", None)
if not desc and module.__doc__:
desc = module.__doc__.strip().split("\n")[0]
desc = desc or "No description available"
plugin_items.append(f"<strong>[{plugin_name}.py]</strong>: {desc}")
active_count = len(plugin_items)
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]
# 1) Alwaysvisible count
count_msg = f"📊 **Total Active Plugins:** {active_count}"
await bot.api.send_markdown_message(room.room_id, count_msg)
if hasattr(module, "__description__"):
description = module.__description__
elif module.__doc__:
description = module.__doc__.strip().split("\n")[0]
else:
description = "No description available"
# 2) Collapsible list
list_html = "<br>".join(plugin_items)
detail_msg = (
f"<details>"
f"<summary><strong>🔌 Plugin List 🔌<br>⤵︎ Click to expand</strong></summary>"
f"<br>{list_html}"
f"</details>"
)
await bot.api.send_markdown_message(room.room_id, detail_msg)
plugin_descriptions.append(f"<strong>[{plugin_name}.py]:</strong> {description}")
plugin_descriptions.sort()
return plugin_descriptions
logging.info(f"Sent plugin list ({active_count} active) to room {room.room_id}")
# ---------------------------------------------------------------------------
# Plugin Metadata
# ---------------------------------------------------------------------------
__version__ = "1.0.0"
__version__ = "1.0.4"
__author__ = "Funguy Bot"
__description__ = "List all loaded plugins"
__description__ = "List all loaded plugins with count, collapsible"
__help__ = """
<details>
<summary><strong>!plugins</strong> List loaded plugins</summary>
<p>Displays all currently loaded plugins and their descriptions.</p>
<summary><strong>!plugins</strong> List active plugins</summary>
<p>Shows the total number of loaded plugins and a collapsible list with descriptions.</p>
</details>
"""