Skip to content

feat: add self flag to message events for echo-message and znc.in/self-message#412

Open
ValwareIRC wants to merge 1 commit intokiwiirc:masterfrom
ValwareIRC:feature/echo-message-self-flag
Open

feat: add self flag to message events for echo-message and znc.in/self-message#412
ValwareIRC wants to merge 1 commit intokiwiirc:masterfrom
ValwareIRC:feature/echo-message-self-flag

Conversation

@ValwareIRC
Copy link
Copy Markdown

Summary

When the echo-message cap (or the znc.in/self-message cap) is active, the server sends back a copy of every PRIVMSG, NOTICE, ACTION, and TAGMSG the client sends. These echoed messages arrive with the client's own nick as the prefix and are currently indistinguishable from any other incoming message at the framework level, forcing every consumer to re-implement the same nick-comparison logic.

Changes

A boolean self field is now included in the privmsg, notice, tagmsg, and action event payloads:

  • self: true when echo-message or znc.in/self-message is enabled AND the sending nick matches the connected user's nick
  • self: false in all other cases (including when no echo cap is active)

The nick comparison uses client.caseCompare() so it correctly respects the server's CASEMAPPING setting.

Testing

11 new tests in test/commands/handlers/messaging.test.js cover:

  • All four event types (privmsg, notice, tagmsg, action)
  • Both cap variants (echo-message and znc.in/self-message)
  • Cap-absent case (self=false)
  • Mismatched nick (self=false)
  • Case-insensitive nick comparison

All 257 tests pass (246 pre-existing + 11 new).

…f-message

When the echo-message cap (or the znc.in/self-message cap) is active,
the server sends back a copy of every PRIVMSG, NOTICE, ACTION, and
TAGMSG the client sends. These echoed messages arrive with the client's
own nick as the prefix and are currently indistinguishable from any
other message at the framework level, forcing each consumer to
re-implement the same nick-comparison logic.

This commit adds a boolean 'self' field to the privmsg, notice, tagmsg,
and action event payloads:
  - self: true  when echo-message (or znc.in/self-message) is enabled
                AND the sending nick matches the connected user's nick
  - self: false in all other cases

The comparison is done via client.caseCompare() so it respects the
server's CASEMAPPING setting.

Tests added in test/commands/handlers/messaging.test.js cover all four
event types, both cap variants, the cap-absent case, a mismatched nick,
and case-insensitive comparison.
@ItsOnlyBinary
Copy link
Copy Markdown
Contributor

I'm not sure this actually solves the issue as i tried something similar with #307 but closed it due to incorrect behaviour.

I think the only real solution is labeled-response, but that is going to need some major library changes to be able to track the labels after message splitting.

@ValwareIRC
Copy link
Copy Markdown
Author

May I ask what incorrect behavior you are experiencing? This seems to work fine for me?

@ItsOnlyBinary
Copy link
Copy Markdown
Contributor

putting comments on why i closed a pr is something i really should learn to do, because i dont remember :(

@ValwareIRC
Copy link
Copy Markdown
Author

Hahaha happens to everyone, give it a try, maybe it's fixed 🤪

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.

2 participants