matterbridge icon indicating copy to clipboard operation
matterbridge copied to clipboard

IRC MessageLength setting has no effect

Open alvinhochun opened this issue 3 years ago • 3 comments

Describe the bug

IRC messages are truncated somewhere but not according to the MessageLength setting and the <message clipped> string is not appended.

To Reproduce

  1. Set MessageLength or use the default 400
  2. Send a long message from another chat and observe the relayed message on the IRC end

Expected behavior

The message should be truncated by MessageLength and the message should end in <message clipped>.

Screenshots/debug logs

Log from my test (with MessageLength=100): 圖片

Environment (please complete the following information):

  • OS: linux
  • Matterbridge version: 1.22.3 e45bbe45

Additional context

[irc.liberachat]
Nick="x"
NickServNick="x"
NickServPassword="x"
Server="irc.libera.chat:6697"
UseTLS=true
UseSASL=true
SkipTLSVerify=false
RemoteNickFormat="[轉自{PROTOCOL}] <{NICK}> "
ShowJoinPart=true
MessageLength=100
MessageSplit=false

[matrix.x]
Server="x"
Login="x"
Password="x"
RemoteNickFormat="[轉自{PROTOCOL}] <{NICK}> "
NoHomeServerSuffix=false
ShowJoinPart=true


[[gateway]]
name="x"
enable=true

[[gateway.inout]]
account="irc.liberachat"
channel="##x"

[[gateway.inout]]
account="matrix.x"
channel="#x:x.x"

alvinhochun avatar Jul 05 '21 08:07 alvinhochun

MessageSplit=false

This is not explained in the Wiki but MessageLength is only used when MessageSplit is used as well (bridge/irc/irc.go#L169-L173):

if b.GetBool("MessageSplit") {
	msgLines = helper.GetSubLines(msg.Text, b.MessageLength, b.GetString("MessageClipped"))
} else {
	msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped"))
}

XRevan86 avatar Jul 09 '21 02:07 XRevan86

MessageLength is only used when MessageSplit is used as well

However the wiki docs on MessageSplit states that

Split messages on MessageLength instead of showing the

implying that, when it is enabled, the "" string is supposed to not be used, in contrast to what the code seems to be doing.

Besides, the original intention of the MessageLength option as implemented for https://github.com/42wim/matterbridge/issues/179 is clearly used to long truncate messages, not just for splitting them.

alvinhochun avatar Jul 09 '21 06:07 alvinhochun

Also if MessageLength could account for the size of the nickname as well, I think it would make things easier.

XRevan86 avatar Jul 09 '21 14:07 XRevan86