Skip to content

feat(relay): relay a bot's own command output to the hub bot - #56

Merged
zznathans merged 1 commit into
mainfrom
feat/relay-command-output
Aug 3, 2026
Merged

feat(relay): relay a bot's own command output to the hub bot#56
zznathans merged 1 commit into
mainfrom
feat/relay-command-output

Conversation

@zznathans

Copy link
Copy Markdown
Owner

Summary

  • A bot's own command output (e.g. a !market reply) sent into its own private group never reached the relay mesh - inc_pgmsg() (Sources/Bot.php) deliberately ignores messages the bot sends to itself (anti-echo-loop guard), so Relay::privgroup()/gmsg() never saw it as an event to act on. Only genuine third-party chat relayed.
  • Hooks the outgoing reply path instead of touching that guard: output_destination() (Commodities/00_BasePassiveModule.php), the single choke point nearly every module's command reply flows through, now also calls a new Relay::relay_command_output() for PG-channel replies.
  • Reuses the existing relay_to_bot() plumbing unchanged, so bots already relaying (like the main/hub bot) need zero changes to start receiving this - it arrives exactly like relayed chat does today.
  • Gated behind a new opt-in Relay.RelayCommandOutput setting (default false) - existing behavior is unchanged until a bot explicitly turns it on via !settings relay relaycommandoutput on.

Test plan

  • CI: php -l lint matrix + PHPUnit unit-test matrix + docs-check (Tests/README.md hand-updated to match generate-readme.php's expected output, no local PHP binary available to run it directly)
  • Manual (post-deploy): enable Relay.RelayCommandOutput on a spoke bot, run a command like !market <search> inside its own private group, confirm the output also shows up relayed on the main/hub bot

🤖 Generated with Claude Code

A bot's own command output (e.g. a !market reply) sent into its own
private group never reached the relay mesh: inc_pgmsg() (Sources/Bot.php)
ignores messages the bot sends to itself to avoid feeding its own
relayed output back into the command dispatcher, so Relay's
privgroup()/gmsg() event handlers never fired for it - only genuine
third-party chat relayed.

Hook the outgoing reply path instead: output_destination()
(Commodities/00_BasePassiveModule.php), the single choke point nearly
every module's command reply flows through, now also calls a new
Relay::relay_command_output() for PG-channel replies. It reuses the
existing relay_to_bot() plumbing unchanged, so the hub and any bot
already relaying (like the main bot) need no changes to receive it.
Gated behind a new opt-in Relay.RelayCommandOutput setting (default
off) so nothing changes until a bot explicitly turns it on.
@github-actions github-actions Bot added documentation Improvements or additions to documentation relay Chat relay modules (IRC/Discord/WebSocket) core Core bot framework (Main/**) tests PHPUnit test suite changes module-relay commodity-base-passive-module labels Aug 3, 2026
@zznathans
zznathans merged commit 3181ad8 into main Aug 3, 2026
15 checks passed
@zznathans
zznathans deleted the feat/relay-command-output branch August 3, 2026 21:26
zznathans pushed a commit that referenced this pull request Aug 4, 2026
This whole feature (relaying a bot's own command output/activity lines
across the mesh, added across #56/#58, partially reverted in #60) turned
out to be more scope and code-base churn than it was worth for what's
actually needed. Fully removing it:

- Modules/Relay.php: drop relay_command_output() and the
  Relay.RelayCommandOutput setting.
- Modules/Ao/Market.php: announce()/announce_background() go back to
  their original single send_pgroup() call - local private-channel
  logging stays exactly as it was before any of this, just no longer
  relayed across bots.
- Commodities/00_BasePassiveModule.php: drop the leftover explanatory
  comment from the #60 revert.
- Tests/Stubs/FakeMarketBot.php, Tests/Stubs/FakeRelayBot.php,
  Tests/Modules/Ao/MarketTest.php, Tests/Modules/RelayTest.php,
  Tests/README.md: back to their pre-#56 state.

Confirmed via `git diff` against the commit before #56 that every touched
file is now byte-identical to its pre-feature state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commodity-base-passive-module core Core bot framework (Main/**) documentation Improvements or additions to documentation module-relay relay Chat relay modules (IRC/Discord/WebSocket) tests PHPUnit test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant