Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape IRC messages as plaintext (i.e. no Markdown formatting) in Telegram #142

Closed
jwflory opened this issue Apr 26, 2019 · 5 comments

Comments

@jwflory
Copy link
Member

commented Apr 26, 2019

Summary

IRC messages sent to Telegram always render as plaintext (i.e. no Markdown formatting rules applied)

Background

When hyperlinks including underscore characters are sent across the bridge, Telegram has suddenly started rendering this as italics:

https://meetbot.fedoraproject.org/fedora-meeting-1/2019-04-25/f30-readiness-meeting.2019-04-25-19.00.log.html

Rendered message in Telegram when URL is sent across TeleIRC

Obviously URLs should render as plain-text only.

Details

This needs investigation. We need to do some message pre-processing on received IRC messages before sending them over to IRC. I think this is an unintended side effect of #134 when we changed parse_mode:

teleirc.tgbot.sendMessage(teleirc.config.tg.chatId, message, { parse_mode: 'markdown' });

Outcome

URLs successfully appear as written when sent across bridge

@jwflory jwflory added this to Backlog in TeleIRC development via automation Apr 26, 2019

@jwflory jwflory added this to the v1.4 milestone Apr 26, 2019

@jwflory jwflory moved this from Backlog to Next sprint in TeleIRC development Apr 26, 2019

@Tjzabel

This comment has been minimized.

Copy link
Member

commented May 26, 2019

Discussion

I'm always hesitant to add more pre-message processing as this adds more overhead to TeleIRC before messages are sent across the bridge.

At the moment, it seems to me that we have several courses of actions with this issue:

  1. Check to see if a message contains http or https in it, and turn off markdown within that section if so
  2. Revert the markdown entirely

Option 1

Course 1 involves parsing every IRC message for a contained string (Does JS have this natively?), and reverting only the web link back to plaintext. This is most likely possible, but would nonetheless add some more overhead to each message. If this is something we are willing to do, then I don't have any issues going forth with this.

Option 2

Course 2 simply reverts all the markdown, getting rid of the IRC bolding. I've gotten quite fond of the IRC bolding Telegram side, as it makes it easy to see when folks are messaging from IRC. This route would need to weigh the pros/cons of having correct links versus having the bold formatting. This is the easiest option.

@Tjzabel

This comment has been minimized.

Copy link
Member

commented May 26, 2019

I created #143 since links are so important. This would go towards Option 2 as a short-term action, while we work on planning out how Option 1 would work.

@xforever1313

This comment has been minimized.

Copy link
Contributor

commented May 26, 2019

The line that introduces the markdown to bold the username is inside of IrcMessageHandler.js:

let message = "<*" + username + "*> " + userMessage;

We're only using markdown to bold the username, and nowhere else (to my knowledge). Could we just escape the user's message so any markdown get escaped? Something like:

let message = "<*" + username + "*> " + Markdown.Escape( userMessage );

Given Node's lackluster standard library, I doubt such function exists without pulling a dependency or rolling our own.

@Tjzabel

This comment has been minimized.

Copy link
Member

commented May 27, 2019

Hm, that could very much be a good solution. Thanks for looking into this!

@jwflory

This comment has been minimized.

Copy link
Member Author

commented May 31, 2019

+1 for @xforever1313's solution. We don't need to parse the message content as Markdown, only the username.

Tjzabel added a commit that referenced this issue Jul 19, 2019

Tjzabel added a commit that referenced this issue Jul 19, 2019

Tjzabel added a commit that referenced this issue Jul 28, 2019

Escape IRC messages as plaintext. Closes #142.
This makes use of the escape-html library in order to remove any formatting from a user's message.
This allows us to bold IRC usernames using HTML syntax, but keeping the message intact.

Tjzabel added a commit that referenced this issue Jul 28, 2019

Escape IRC messages as plaintext. Closes #142.
This makes use of the escape-html library in order to remove any formatting from a user's message.
This allows us to bold IRC usernames using HTML syntax, but keeping the message intact.

TravisCI does not need to notify #rit-lug-sysadmin channel.

Remove all caching.

@Tjzabel Tjzabel moved this from Next sprint to In progress in TeleIRC development Jul 28, 2019

@jwflory jwflory closed this in #156 Aug 1, 2019

TeleIRC development automation moved this from In progress to Done Aug 1, 2019

jwflory added a commit that referenced this issue Aug 1, 2019

Escape IRC messages as plaintext. Closes #142.
This makes use of the escape-html library in order to remove any formatting from a user's message.
This allows us to bold IRC usernames using HTML syntax, but keeping the message intact.

TravisCI does not need to notify #rit-lug-sysadmin channel.

Remove all caching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.