Add color coding.

This commit is contained in:
AZ Huang 2014-02-21 02:28:35 +08:00
parent b5ad3dccd5
commit f16590f4ed

View File

@ -151,6 +151,8 @@ class SyncBot(Tox):
name = self.group_peername(groupnumber, friendgroupnumber) name = self.group_peername(groupnumber, friendgroupnumber)
if name != NAME: if name != NAME:
print('TOX> %s: %s' % (name, message)) print('TOX> %s: %s' % (name, message))
if message.startswith('>'):
message = '\x0309%s\03' % message
if message.startswith('^'): if message.startswith('^'):
self.irc_send('PRIVMSG %s :%s\r\n' % (CHANNEL, message)) self.irc_send('PRIVMSG %s :%s\r\n' % (CHANNEL, message))
self.handle_command(message) self.handle_command(message)
@ -161,8 +163,9 @@ class SyncBot(Tox):
def on_group_action(self, groupnumber, friendgroupnumber, action): def on_group_action(self, groupnumber, friendgroupnumber, action):
name = self.group_peername(groupnumber, friendgroupnumber) name = self.group_peername(groupnumber, friendgroupnumber)
if name != NAME: if name != NAME:
name = self.group_peername(groupnumber, friendgroupnumber)
print('TOX> %s: %s' % (name, action)) print('TOX> %s: %s' % (name, action))
if action.startswith('>'):
action = '\x0309%s\03' % action
self.irc_send('PRIVMSG %s :\x01ACTION [%s]: %s\x01\r\n' % self.irc_send('PRIVMSG %s :\x01ACTION [%s]: %s\x01\r\n' %
(CHANNEL, name, action)) (CHANNEL, name, action))