45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
# file covert_agent.py
|
|
# author Florent Guiotte <florent.guiotte@irisa.fr>
|
|
# version 0.2
|
|
# date 16 avril 2020
|
|
"""
|
|
Place this file here (╯°□°)╯︵ ~/.config/hexchat/addons
|
|
"""
|
|
|
|
import hexchat
|
|
import re
|
|
|
|
__module_name__ = 'CovertAgent'
|
|
__module_version__ = '0.2'
|
|
__module_description__ = 'Display nicknames through discord bridge'
|
|
|
|
BRIDGE_NAME = 'interbot'
|
|
|
|
edited = False
|
|
|
|
def parse_nick(word, word_eol, userdata):
|
|
global edited
|
|
if edited:
|
|
return
|
|
|
|
nick = word[0]
|
|
|
|
if not BRIDGE_NAME in nick:
|
|
return hexchat.EAT_NONE
|
|
|
|
ca_nick = re.search('<.*?>', word[1]).group().strip('<>')
|
|
new_msg = re.sub('<.*?> ', '', word[1])
|
|
new_nick = '► {}'.format(ca_nick)
|
|
word[0] = new_nick
|
|
word[1] = new_msg
|
|
|
|
edited = True
|
|
hexchat.emit_print(userdata, *word)
|
|
edited = False
|
|
|
|
return hexchat.EAT_ALL
|
|
|
|
hexchat.hook_print('Channel Message', parse_nick, 'Channel Message', priority=hexchat.PRI_HIGHEST)
|
|
hexchat.hook_print('Channel Msg Hilight', parse_nick, 'Channel Msg Hilight', priority=hexchat.PRI_HIGHEST)
|