errbot icon indicating copy to clipboard operation
errbot copied to clipboard

Cannot set background color of text on IRC

Open kryptek opened this issue 8 years ago • 4 comments

How do I send colored text to IRC from errbot? My client is textual but it doesn't seem to be rendering any color.

I've tried several different methods:

return "\033[0;32mTest\033[0m"
return "{}Test".format(IRC_CHRS.fg_green)
return "\e[0;32mTest\e[0m"
return "\x0303Test\x0F"

Neither of these methods send colored text to IRC. I'm using the Textual IRC client. Can someone please point me in the right direction?

kryptek avatar Feb 15 '17 22:02 kryptek

Hi @kryptek!

By design it is not possible to inject colors this way. Because errbot tries to be chat-network agnostic it also abstracts away implementation-specific color codes. In errbot we've made the choice of letting Markdown be the input format, so your plugin is expected to produce some Markdown text and then the bot will do the hard work of rendering it the best it can for your given chat network.

I just realized this isn't properly documented on http://errbot.io under Plugin development, we need to fix that.

You can find an example of the expected Markdown syntax in test.md. If you execute !render_test on your bot instance, you'll actually see how that renders on your network.

I'm not 100% our Markdown-to-IRC converter also supports colors, but I think it does.

zoni avatar Feb 16 '17 19:02 zoni

Thanks for the reply, Seems to work for foreground colors on IRC but background colors don't get rendered.

return "`red on black`{:color='red' :bgcolor='black'}"

kryptek avatar Feb 20 '17 21:02 kryptek

Right. I think IRC is (currently) the only backend where setting background colors makes any sense (but even there, some people argue you shouldn't :wink:) so it's not altogether surprising that doesn't work.

I will update the title of this issue and make it a feature-request. I personally don't have motivation to work on this though so an implementation will have to be contributed by someone else.

zoni avatar Feb 21 '17 08:02 zoni

Those are the code available for fg and bg, is the bg_black correct ?

                          fg_black=NSC('\x0301'),
                          fg_red=NSC('\x0304'),
                          fg_green=NSC('\x0303'),
                          fg_yellow=NSC('\x0308'),
                          fg_blue=NSC('\x0302'),
                          fg_magenta=NSC('\x0306'),
                          fg_cyan=NSC('\x0310'),
                          fg_white=NSC('\x0300'),
                          fg_default=NSC('\x03'),
                          bg_black=NSC('\x03,01'),
                          bg_red=NSC('\x03,04'),
                          bg_green=NSC('\x03,03'),
                          bg_yellow=NSC('\x03,08'),
                          bg_blue=NSC('\x03,02'),
                          bg_magenta=NSC('\x03,06'),
                          bg_cyan=NSC('\x03,10'),
                          bg_white=NSC('\x03,00'),
                          bg_default=NSC('\x03,'),

gbin avatar Mar 25 '17 14:03 gbin