lrstanley / girc

:bomb: girc is a flexible IRC library for Go :ok_hand:
https://pkg.go.dev/github.com/lrstanley/girc
MIT License
137 stars 13 forks source link

bug: newlines are removed instead of changed to a space #55

Closed half-duplex closed 1 year ago

half-duplex commented 2 years ago

🌧 Describe the problem

When calling Cmd.Message() with a message containing a newline, the newline is stripped, which smashes words together.

⛅ Expected behavior

The newline should be replaced with a space, instead of just stripped

🔄 Minimal reproduction

Call Cmd.Message("#foo", "example\nmessage") and observe that the resulting message is "examplemessage" instead of "example message"

💠 Version: girc

v0.0.0-20220410132120-49de39aea653

🖥 Version: Operating system

linux/other

⚙ Additional context

I'm using girc via https://github.com/RITlug/teleirc . When a telegram message contains a newline, the resulting IRC message has this problem. It could be worked around in TeleIRC, but it seemed like girc would be a better place to fix it for everyone.

I'm not sure the best way to handle \r or \r\n - ideally collapsing runs of either to just one space?

🤝 Requirements

lrstanley commented 2 years ago

I do think replacing newlines with spaces is a sufficient short-term solution, but I may finally start taking a look at #43, as that'd also resolve this. I'll try and take a look later today.

half-duplex commented 2 years ago

Thanks! Another option, though this one may be better implemented by applications than girc: sopel-twitter replaces newlines with " ⏎ "

lrstanley commented 1 year ago

Should be implemented via https://github.com/lrstanley/girc/pull/43 -- let me know if you have any further issues.