natsim

NATS ↔ Instant Messaging Bridge
git clone https://git.instinctive.eu/natsim.git
Log | Files | Refs | README | LICENSE

commit 9a92b967b37bcebc802e15c5cd46a04b10c4d2d4
parent a0d9cf01bbe8a99ca103c0c71018e5993b505715
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date:   Tue, 12 Aug 2025 17:50:25 +0000

Quote ratio before falling back to hexadecimal is configurable
Diffstat:
Mmain.go | 52+++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/main.go b/main.go @@ -71,25 +71,26 @@ type LineMark struct { } type IrcConfig struct { - Channel string - Server string - Nick string - Cmd LineMark - Send LineMark - Show LineMark - ShowReply *LineMark - ShowHeader *LineMark - MaxLine int - ContSuffix string - ContPrefix string - AntiFlood antiflood - Filter []FilterElement - AutoClear bool - nextClear bool - AllowCmd []string - AllowSend []string - BlockCmd []string - BlockSend []string + Channel string + Server string + Nick string + Cmd LineMark + Send LineMark + Show LineMark + ShowReply *LineMark + ShowHeader *LineMark + MaxLine int + ContSuffix string + ContPrefix string + AntiFlood antiflood + Filter []FilterElement + AutoClear bool + nextClear bool + AllowCmd []string + AllowSend []string + BlockCmd []string + BlockSend []string + MaxQuoteRatio float32 } type LogConfig struct { @@ -130,11 +131,12 @@ type NatsIM struct { func NewNatsIM(configPath string) (*NatsIM, error) { natsim := &NatsIM{ Irc: IrcConfig{ - Nick: "natsim", - Cmd: LineMark{Start: "!", Mid: " "}, - Send: LineMark{Mid: ": "}, - Show: LineMark{Mid: ": "}, - AutoClear: true, + Nick: "natsim", + Cmd: LineMark{Start: "!", Mid: " "}, + Send: LineMark{Mid: ": "}, + Show: LineMark{Mid: ": "}, + AutoClear: true, + MaxQuoteRatio: 2.0, }, Nats: NatsConfig{ Name: "nastim", @@ -669,7 +671,7 @@ func (natsim *NatsIM) ircQuoteData(data []byte) string { } quoted.WriteString(strings.Repeat("\\n", suffix)) - if quoted.Len() >= 2*len(data) { + if quoted.Len() >= int(natsim.Irc.MaxQuoteRatio*float32(len(data))) { return "#" + hex.EncodeToString(data) + "#" } return quoted.String()