bitlbee-discord icon indicating copy to clipboard operation
bitlbee-discord copied to clipboard

Fix Multiline support through Pastebuffer

Open tecknojock opened this issue 8 years ago • 12 comments

Discord will reject messages sent with new lines, which if you have pastebuffer enabled on bitlbee, when you split it will add in new lines.

Pastebuffer merges multiple messages into one single message when sent within a certain period of time.

~~Therefore, either new lines should trigger a split into a separate message, or they should just be stripped out altogether.~~

Update: Really the above fix that we did, is more of a jury rig, especially since discord does now support multi-line messages. So, the question becomes, why is discord rejecting multiline messages? Its generating a 400 error, which is a bad request.

tecknojock avatar Aug 12 '16 19:08 tecknojock

Couldn't test it out myself since both irssi and xchat seem to split messages on \n, but 2d27e5e should fix you problem. Could you please confirm that for me?

sm00th avatar Aug 16 '16 10:08 sm00th

You have to enable the "paste_buffer" option and then Bitlbee will concatenate all messages received within 200 ms of the first. But sure, I'll test

tecknojock avatar Aug 16 '16 12:08 tecknojock

Well the messages send properly and no longer error out...but after seeing the output, it might be better if the /n is converted to a space. It runs the lines together.

Thanks again.

tecknojock avatar Aug 16 '16 15:08 tecknojock

Makes sense, c4f3426 does that.

sm00th avatar Aug 18 '16 14:08 sm00th

Thanks~ Great fix. I think this can be closed.

tecknojock avatar Aug 18 '16 14:08 tecknojock

It seems perhaps that discord allows new lines now, so perhaps this concatting is no longer needed?

tecknojock avatar Apr 03 '17 18:04 tecknojock

Hmm I've tried messing with this, and despite discord allowing mutliline, neither removing this stripping of /r/n, nor making it only strip /r seems to still result in a failure to send a message.

tecknojock avatar Dec 16 '17 06:12 tecknojock

hi, not sure the support status of bitlbee-discord, so just posting here in case this helps anyone. It seems the problem is that the replacement string needs to be escaped properly as well. That is, in c4f3426, the " " should be "\\r\\n". (Seeing how the tab is escaped above was the clue.) That seems to fix things for me and I can use paste_buffer with no problems. Sorry for the spam.

lethal-click avatar Sep 27 '19 06:09 lethal-click

Hey there, @lethal-click. The support status is "maintenance only" but I'd be glad to merge this if you can create a pull-request with your changes and we can ask someone (like @tecknojock) to test it out.

sm00th avatar Sep 27 '19 07:09 sm00th

hey, sorry, but I don't have Git or anything like that installed. I literally just hacked the change in and recompiled locally. I only posted in the hope that anyone else with the same problem would find this handy (much gratitude to you @sm00th for making bitlbee-discord in the first place).

the diff is literally just the following on the tip of master:

363c363,364
<   nmsg = g_regex_replace_literal(escregex, emsg, -1, 0, " ", 0, NULL);
---
>   nmsg = g_regex_replace_literal(escregex, emsg, -1, 0, "\\r\\n", 0, NULL);

in case someone else is able to submit the pull request.

lethal-click avatar Sep 28 '19 09:09 lethal-click

For small things like this, the web interface is easier.

Either way, submitted per your request. #196

Alcaro avatar Sep 28 '19 09:09 Alcaro

thanks @Alcaro, looks good. Hope someone is able to get some use out of this.

lethal-click avatar Sep 30 '19 23:09 lethal-click