-
Notifications
You must be signed in to change notification settings - Fork 272
Color Codes in chat not supported #210
Comments
Yes, bold, italic, and underline don't work also. |
There's already a library for parsing colour codes in Javascript at: https://github.com/megawac/irc-style-parser Perhaps shout could use this? |
The IRC style parser seems like it should work but it doesn't. I'm unsure why. It could be that not all the raw IRC data is being passed through Slate-IRC. |
The text strings for IRC users who are styling their chat with colors are being prefixed with a number code. ##,## This indicates the text color(foreground) and background respectively. Here is a copy paste from a chat, notice the 09,02 08,01 ... As you can see it is distracting for our users. |
Here is a JSFiddle I've messed with using some regular expressions to convert the mIRC colors to HTML. It's just a proof of concept using jQuery. http://jsfiddle.net/spencerthayer/tqajge2z/ IRC sends a hack unicode character before the color or text styling. In RegEx they appear like this: The Fiddle takes that data being sent through chat and replaces the data with HTML styling. As of right now it doesn't work with Shout. I am certain the RegEx replacement script would need to be initiated upon every new chat record, which I cannot seem to find the right function to piggy back off of. |
Ah, nice that you moved the messages, @spencerthayer Anyway, I have to test the text codes. I need to know if it gets send to the client, or if it's stripped away in the backend. Because if it's sent to the client, it might be easy to fix. Every message get passed through this Handlebars helper (client-side): The helper is called from here: |
@erming it gets delivered to the client. I have tested it using .charCodeAt()... It just needs implementing... |
@spencerthayer if you use .charCodeAt you can confirm that the character gets sent to the client... Alternatively just check in the backend code |
I created a JSPerf test to check the regex performance: http://jsperf.com/mirctohtml |
Is that performance acceptable? I'm working on integrating the code into parse.js right now. |
Yes it is! Oh, sure! It's great if you want to do it. That leaves me time to work on something else. |
Unfortunately this regex doesn't seem to conform with mIRC control codes 😞 |
This is what I have currently. http://pastebin.com/btAbN6Ka I haven't tested it yet to see if it even makes sense. |
Looks good, @spencerthayer |
@wizardfrag That's weird because when I inspect a chat element and select copy HTML and paste into the HTML section on my jsFiddle it always reproduces the correct styling. |
@spencerthayer from what I can tell, if you do "\02Hello \034World\02 today" the "today" part isn't coloured. Try that with mIRC... |
Shouldn't be hard to port the test cases I wrote a while ago to see how complaint you guys are with mIRC (if you don't mind tap). I spent a couple evenings getting it down as tight as I could. For instance you guys aren't handling ^0 break codes, which are ridiculously easy to support recursively |
It would be nice if the code could work without Lodash/Underscore. I think colors are really a just a minor feature, and less code, the better. |
For some reason the code I added parse.js (linked in previous post) isn't working. If it did it could be a decent break fix. Not perfect but decent. |
Yeah, I've been meaning to make that code underscore agnostic for a while. On Mon, Oct 6, 2014 at 3:56 PM, Mattias Erming notifications@github.com
|
Also; in the future it would be nice if color was visible in the "send message" bar.. that might be a little resource intensive though. Inserting color codes:.. |
@erming Any idea what I was doing wrong? |
Oh, I misinterpreted your post, @spencerthayer.
I'm going to crank out some code for a couple of hours right now. I'll look into it. |
Added here: d86005e While Shout now supports rendering text colors sent from others, I'm not really sure if/how I should implement sending colors. I don't think it's a useful feature. |
Thanks for the code btw, @spencerthayer! I think it works great. I only made some slight modifications to it (fixed variable scope and changed names). |
Okay so the CSS code you are using doesn't work in every case. mIRC colors, depending on software and version, will use 1 or 01. The CSS below will work for every color instance.
|
Here is a patch since I cannot figure out how to send you a commit. http://ge.tt/8PdwMT12/v/0 |
I assume this means BOLD isn't supported either, but I don't have proof of that.
I get
04H��07A��08P��03P��12Y� �02B��06J��04R��07T��08H��03D��12A��02Y� �06B��04A��07L��08L��03K��12E��02N��06E��04N��07D��08E��03_��12!
instead of the expected rainbow colored output.Not a priority by any means, a channel I'm in just has a lot of commands for a bot that happen to have colored output.
The text was updated successfully, but these errors were encountered: