Skip to content

fix: honor poke reply toggle#124

Open
Rat0323 wants to merge 2 commits into
Renyus:masterfrom
Rat0323:codex/fix-poke-reply-toggle
Open

fix: honor poke reply toggle#124
Rat0323 wants to merge 2 commits into
Renyus:masterfrom
Rat0323:codex/fix-poke-reply-toggle

Conversation

@Rat0323

@Rat0323 Rat0323 commented Jun 15, 2026

Copy link
Copy Markdown

Summary

  • Honor the existing poke_reply_enabled setting before scheduling poke replies.
  • Add a regression contract test so the poke handler keeps checking the toggle.
  • Document the fix in CHANGELOG.md under Unreleased.

Problem

The plugin exposes poke_reply_enabled in both _conf_schema.json and PluginConfig, and the schema says disabling it should stop poke interactions. However, the on_message_listener poke branch always schedules _poke_reply_async() whenever the bot is poked:

if target_id == bot_id:
    asyncio.create_task(_poke_reply_async(...))

As a result, setting poke_reply_enabled to false does not actually prevent the bot from poking back or sending a random complaint text.

Fix

The handler now checks the toggle before scheduling the poke reply task:

if target_id == bot_id and self.cfg.poke_reply_enabled:
    asyncio.create_task(_poke_reply_async(...))

The event is still stopped after handling a Poke component, preserving the existing event propagation behavior.

Tests

  • python -m unittest tests.test_config_contract
  • python -m py_compile main.py tests\test_config_contract.py

Note: ruff check main.py tests/test_config_contract.py currently reports many pre-existing lint issues in unchanged code, so it is not clean on this branch.

@Rat0323

Rat0323 commented Jun 15, 2026

Copy link
Copy Markdown
Author

I added a follow-up commit (302c598) to strengthen the regression coverage.

The previous test checked for the guard as text. It now parses main.py with ast and verifies that the direct asyncio.create_task(_poke_reply_async(...)) call is guarded by:

target_id == bot_id and self.cfg.poke_reply_enabled

Validation run locally:

python -m unittest tests.test_config_contract
python -m py_compile main.py tests\test_config_contract.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant