chat bridge: stop Discord lines echoing back into clan chat - #55
Open
joelhalen wants to merge 1 commit into
Open
chat bridge: stop Discord lines echoing back into clan chat#55joelhalen wants to merge 1 commit into
joelhalen wants to merge 1 commit into
Conversation
The Discord→game direction feeds straight back into the game→Discord one. Rendering a Discord line calls through to client.addChatMessage, which posts a real ChatMessage, so our own injected line arrives at the plugin's chat subscriber indistinguishable from something a clanmate typed — and gets relayed back to Discord, into the channel it was just typed in. The suffix that keeps a Discord user from being mistaken for a clanmate is also what identifies our own renders, so it becomes a named constant, DISCORD_SENDER_MARKER, and ClanRelayService.onClanChat drops any CLAN_CHAT line whose sender wears it. An in-game display name cannot contain parentheses, so no real clanmate is ever caught by the test. The check is a substring rather than a suffix match: the marker is appended at the end today, but the guard has to keep holding if the rendered name is ever decorated further, and no real name can contain it either way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ClanRelayService.onClanChatnow drops anyCLAN_CHATline whose sender carries the Discord marker, and that marker becomes a named constantChatMessageUtil.DISCORD_SENDER_MARKERrather than a literal written in one place and matched in none.Why
The two directions of the bridge feed into each other. Rendering a Discord line goes through
client.addChatMessage, which posts a realChatMessage— so our own injected line arrives at the plugin's chat subscriber indistinguishable from something a clanmate typed, and gets relayed back to Discord, into the channel it was just typed in.The suffix that stops a Discord user being mistaken for an in-game clanmate is also what identifies our own renders, so it does double duty. An in-game display name cannot contain parentheses, so no real clanmate is ever caught by the test.
The check is a substring rather than a suffix match: the marker is appended at the end today, but the guard has to keep holding if the rendered name is ever decorated further, and no real name can contain it either way.
Note
One unrelated fix rides along: the new constant had been inserted between
sendEventChatMessage's javadoc and the method itself, leaving the javadoc dangling above a field and the method undocumented. Java accepts two javadoc blocks in a row and silently ignores the first, so this compiled clean. The javadoc is moved back onto its method.Verification
Full suite green: 251 tests, 0 failures. No behavioural test covers the guard itself — see the PR discussion.