-
Notifications
You must be signed in to change notification settings - Fork 1
/
noticetofront.py
45 lines (36 loc) · 1.46 KB
/
noticetofront.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import hexchat
__module_name__ = "Notice to front"
__module_version__ = "0.2"
__module_description__ = "Prints notices to active window regardless of server"
__author__ = "Nathan (nathh_)"
def processNotice(word, word_eol, userdata):
current_tab = hexchat.find_context()
if not current_tab:
return hexchat.EAT_NONE
nick = word[0].split("!")[0].replace(":", "")
noticecontent = getnoticetext(word)
if nick and noticecontent:
notice_network = hexchat.get_info("network")
notice_host = hexchat.get_info("host")
currenttab_network = current_tab.get_info("network")
if notice_network == currenttab_network:
current_tab.emit_print("Notice", nick, noticecontent)
else:
current_tab.emit_print("Notice", nick, "(%s / %s): %s" % (notice_network, notice_host, noticecontent))
return hexchat.EAT_ALL
hexchat.hook_server("NOTICE", processNotice)
def getnoticetext(noticedata):
current_word = 3 # server, NOTICE, nick
notice_content = []
while current_word < len(noticedata):
if noticedata[current_word] == "":
continue
if noticedata[current_word][0] == ":" and current_word == 3:
noticedata[current_word] = noticedata[current_word][1:]
notice_content.append(noticedata[current_word])
current_word = current_word + 1
return ' '.join(notice_content)
def addon_unloaded(userdata):
print "\0034 %s (%s) unloaded." % (__module_name__, __module_version__)
hexchat.hook_unload(addon_unloaded)
print "\0034 %s (%s) loaded." % (__module_name__, __module_version__)