fix(bot): un-reacting from a poll never un-counted the vote
Lint / Shell (shellcheck) (push) Successful in 15s
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 15s
Lint / Python deps (pip-audit) (push) Successful in 3m0s
Lint / Secret scan (gitleaks) (push) Successful in 10s

wyr/acronym/nhie/hottake tracked votes only on reaction-add, using
"add to bucket A, remove from bucket B" logic that self-corrects when
switching reactions but not when a reaction is simply removed — nio
never subscribed to RedactionEvent at all, so an un-react was
invisible to the bot. Fixes LotusGuild/matrix#6 (repro: react agree
and disagree, remove disagree, still counted as disagree).

Adds unrecord_* counterparts to each record_* vote function, a
reaction_id -> (poll_event_id, sender) index in Callbacks (only
populated for reactions on messages we're actually tracking, so it
stays bounded) so a later redaction can be traced back to what to
un-count, and wires up RedactionEvent -> callbacks.redaction in bot.py.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-31 21:19:06 -04:00
co-authored by Claude Sonnet 5
parent cccd0084fb
commit ea7ecf3f73
3 changed files with 84 additions and 0 deletions
+2
View File
@@ -10,6 +10,7 @@ from nio import (
InviteMemberEvent,
LoginResponse,
ReactionEvent,
RedactionEvent,
RoomMemberEvent,
RoomMessageText,
UnknownEvent,
@@ -146,6 +147,7 @@ async def main():
client.add_event_callback(callbacks.message, RoomMessageText)
client.add_event_callback(callbacks.reaction, ReactionEvent)
client.add_event_callback(callbacks.unknown_event, UnknownEvent)
client.add_event_callback(callbacks.redaction, RedactionEvent)
client.add_event_callback(callbacks.member, RoomMemberEvent)
# Accept invites only from trusted users, and decline the rest so they do