From 9598f752c105d94498b394297ea61834f9891d46 Mon Sep 17 00:00:00 2001 From: Viktor AI Date: Tue, 12 May 2026 12:53:18 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20Wormhole=20v3.4.2=20=E2=80=94=20empty-pr?= =?UTF-8?q?efix=20command=20filter=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v3.4.1 command filter used bot.get_context() to detect commands, but an empty-string prefix ('') matched EVERY message, causing ctx.valid to return True for any message whose first word happened to be a registered command. With enough built-in commands (help, ping, info, set, etc.) this silently dropped most or all relay traffic (total_messages stayed at 0). Fix: require ctx.prefix to be truthy (non-empty) before skipping a message as a command. Empty-prefix matches are now ignored, so only messages with a real prefix (!, @bot, etc.) are filtered. Also re-added the empty-prefix warning to 'wh debug' output so users know to clean up their bot prefix configuration. --- wormhole/info.json | 2 +- wormhole/wormhole.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wormhole/info.json b/wormhole/info.json index 6bfabd0..9810b40 100644 --- a/wormhole/info.json +++ b/wormhole/info.json @@ -1,6 +1,6 @@ { "author": ["everestmcarthur"], - "install_msg": "Thanks for installing **Wormhole v3.4.1** — the ultimate cross-server relay!\n\nGet started: `[p]wh create ` then `[p]wh open ` in channels you want to link.\n\nNew in v3.4.1: Relay engine hardening — command filter uses Red's internal command resolution (no more dropped messages), top-level error handling, safer background loops.\n\nFull help: `[p]wh help` or `/wh help`", + "install_msg": "Thanks for installing **Wormhole v3.4.2** — the ultimate cross-server relay!\n\nGet started: `[p]wh create ` then `[p]wh open ` in channels you want to link.\n\nNew in v3.4.2: Fixed empty-prefix bug that silently blocked all relay traffic. Command filter now correctly ignores empty-string prefixes. v3.4.1: Relay engine hardening — command filter uses Red's internal command resolution (no more dropped messages), top-level error handling, safer background loops.\n\nFull help: `[p]wh help` or `/wh help`", "name": "Wormhole", "disabled": false, "short": "The ultimate cross-server relay — hybrid commands, context menus, ToS, reports, mentions policy, 85+ commands.", diff --git a/wormhole/wormhole.py b/wormhole/wormhole.py index 7ae7147..ac68b43 100644 --- a/wormhole/wormhole.py +++ b/wormhole/wormhole.py @@ -25,6 +25,10 @@ Phase 5.1: Relay engine hardening — replaced heuristic command filter with Red's internal bot.get_context() (only real commands filtered), top-level try/except around entire relay chain, safe AFK/auto-response calls, blackout loop no longer overrides manual freeze +Phase 5.2: Fix empty-prefix bug — get_context() with an empty-string prefix + matched every message, silently blocking all relay traffic. Now + requires ctx.prefix to be non-empty before filtering. Re-added + empty-prefix warning to wh debug. """ from __future__ import annotations @@ -373,7 +377,7 @@ class _ReportModal(discord.ui.Modal, title="Report Message"): class Wormhole(commands.Cog): """The ultimate cross-server relay: networks, DMs, starboard, auto-mod, invites, portals & more.""" - __version__ = "3.4.1" + __version__ = "3.4.2" def __init__(self, bot: Red): self.bot = bot @@ -3650,7 +3654,11 @@ class Wormhole(commands.Cog): if isinstance(pfx, str): pfx = [pfx] pfx_display = [f"`{p}`" if p.strip() else f"`(empty)`" for p in pfx[:5]] lines.append(f"\n**Prefixes:** {', '.join(pfx_display)}") - lines.append("**Command filter:** `bot.get_context()` — only registered commands are skipped") + empty_pfx = any(p == "" for p in pfx) + if empty_pfx: + lines.append("⚠️ **Empty prefix detected!** Messages matching commands via the empty prefix " + "may be incorrectly filtered. Use `[p]set prefix` to remove it.") + lines.append("**Command filter:** `bot.get_context()` — only prefixed commands are skipped") await ctx.send(embed=info_embed("\n".join(lines), title="🔧 Wormhole Debug")) @@ -3685,11 +3693,13 @@ class Wormhole(commands.Cog): # ── COMMAND FILTERING ─────────────────────────────────────────────── # Use Red's internal command resolution — only skip messages that are - # actual registered bot commands. No prefix guessing or heuristics. + # actual registered bot commands with a real (non-empty) prefix. + # An empty-string prefix matches every message, so we must ignore it + # to avoid silently dropping all relay traffic. if message.content: try: ctx = await self.bot.get_context(message) - if ctx.valid: + if ctx.valid and ctx.prefix: return except Exception: pass