errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 616 forks source link

Cannot set background color of text on IRC #967

Open kryptek opened 7 years ago

kryptek commented 7 years ago

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?

zoni commented 7 years ago

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.

kryptek commented 7 years ago

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'}"
zoni commented 7 years ago

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.

gbin commented 7 years ago

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,'),