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

Add irc.utils.irc_color_to_ansi() #249

Merged
merged 1 commit into from Sep 18, 2018

Conversation

Projects
None yet
2 participants
@spaceone
Copy link
Contributor

spaceone commented Sep 17, 2018

Translates IRC color/bold/etc codes into ANSI escape sequences, so that the output can be printed on a terminal.

Example:

from circuits.protocols.irc.utils import irc_color_to_ansi
colorstring = '\x0300white\x03 \x0301black\x03 \x0302blue\x03 \x0303green\x03 \x0304red\x03 '
colorstring += '\x0305brown\x03 \x0306magenta\x03 \x0307orange\x03 \x0308yellow\x03 '
colorstring += '\x0309lightgreen\x03 \x0310cyan\x03 \x0311lightcyan\x03 \x0312lightblue\x03 '
colorstring += '\x0313pink\x03 \x0314grey\x03 \x0315lightgrey\x03\x0f'
print(irc_color_to_ansi('hi \x02bold\x02 \x1ditalic\x1d \x1funderline\x1f \x1estrikethrough\x1e'))
print(irc_color_to_ansi(colorstring))
print(irc_color_to_ansi(colorstring.replace(' \x03', ' \x0301,')))

@spaceone spaceone requested a review from prologic Sep 17, 2018

@spaceone spaceone self-assigned this Sep 17, 2018

Add irc.utils.irc_color_to_ansi()
from circuits.protocols.irc.utils import irc_color_to_ansi
colorstring = '\x0300white\x03 \x0301black\x03 \x0302blue\x03 \x0303green\x03 \x0304red\x03 '
colorstring += '\x0305brown\x03 \x0306magenta\x03 \x0307orange\x03 \x0308yellow\x03 '
colorstring += '\x0309lightgreen\x03 \x0310cyan\x03 \x0311lightcyan\x03 \x0312lightblue\x03 '
colorstring += '\x0313pink\x03 \x0314grey\x03 \x0315lightgrey\x03\x0f'
print(irc_color_to_ansi('hi \x02bold\x02 \x1ditalic\x1d \x1funderline\x1f \x1estrikethrough\x1e'))
print(irc_color_to_ansi(colorstring))
print(irc_color_to_ansi(colorstring.replace(' \x03', ' \x0301,')))

@spaceone spaceone force-pushed the irc_ansi_color branch from dfc7e8d to 63a3cb1 Sep 18, 2018

@spaceone

This comment has been minimized.

Copy link
Contributor

spaceone commented Sep 18, 2018

I added a test case :-)

@prologic prologic merged commit 4923743 into master Sep 18, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@spaceone spaceone deleted the irc_ansi_color branch Nov 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment