Skip to content

Commit

Permalink
Fix empty CTCP ACTION sending two literal underscores on Discord
Browse files Browse the repository at this point in the history
Wrapping of IRC CTCP ACTION commands with underscores to mimic the italicization on Discord happens before the logic for ZWB treatment of empty messages. This means that we send two underscore characters for an empty CTCP ACTION, which renders as literal underscores in the Discord UI (instead of the intended empty message). 

This commit fixes it by not wrapping a CTCP ACTION with underscores if it is empty. Having any non-zero whitespace in the CTCP ACTION will not cause this issue (only the true empty string), as Discord renders the sequence `_ _` as empty but `__` as two underscores.
  • Loading branch information
yutotakano authored Nov 9, 2024
1 parent f4098ec commit ee8eaba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bridge/irc_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ func (i *ircListener) OnPrivateMessage(e *irc.Event) {
replacements...,
).Replace(e.Message())

if e.Code == "CTCP_ACTION" {

// Italicize the /me action so it appears like Discord's /me functionality.
// We don't do it for empty messages, since Discord will show two literal underscores.
// Sending empty messages onto the discordMessagesChan is fine, since the sender will
// take care of inserting ZWBs if necessary.
if e.Code == "CTCP_ACTION" && msg != "" {
msg = "_" + msg + "_"
}

msg = ircf.BlocksToMarkdown(ircf.Parse(msg))

go func(e *irc.Event) {
Expand Down

0 comments on commit ee8eaba

Please sign in to comment.