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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
"""X-Chat 2.0 plugin to hide what ignored people say on channel.
Messages from people (nicknames) that are ignored (using /ignore) are
printed with the same foreground and background color. This is better
than normal /ignore, since it reduces your confusion by making it clear
that the ignored people are talking. Also, you can select the text with
a mouse and see what they're saying, in case it is something important.
(If you do that a lot, there's no point in using /ignore, though.)
Place in your .xchat2 directory and either reload X-Chat or
/PY LOAD whiteout.py
0.2 15 Aug 2005 Remove ":+" and ":-" prefixes from the message of
a user. I should read about the IRC protocol.
0.1 10 Aug 2005 Initial version, based on Scott James Remnant's
topicdiff.py.
"""
__author__ = "Lars Wirzenius <liw@iki.fi>"
__copyright__ = "Copyright 2005 Lars Wirzenius <liw@iki.fi>."
__licence__ = "MIT"
__module_name__ = "whiteout"
__module_version__ = "0.2"
__module_description__ = \
"Show ignored channel messages with same fore/background color"
import re
import xchat
# Change this to select the color you want to use.
COLOR = 0
nick_pattern = re.compile(r":(?P<nick>[^!]+)!")
def matches_ignore_mask(mask, userspec):
regexp = ":" # userspec always seems to start with a colon
for c in mask:
if c == "*":
regexp += ".*"
elif c == "?":
regexp += "."
elif c in ".\\":
regexp += "\\" + c
else:
regexp += c
if "!" not in mask:
regexp += "!.*"
return re.match(regexp, userspec) != None
def is_ignored(userspec):
for ignored in xchat.get_list("ignore"):
if ignored.flags & 1 and matches_ignore_mask(ignored.mask, userspec):
return True
return False
def parse_nickname(userspec):
m = nick_pattern.match(userspec)
if m:
return m.group("nick")
else:
return None
def privmsg_cb(word, word_eol, userdata):
ctx = xchat.get_context()
channel = ctx.get_info("channel")
nickname = parse_nickname(word[0])
if is_ignored(word[0]):
start_color = "\003%02d,%02d" % (COLOR, COLOR)
end_color = "\003"
msg = word_eol[3]
if msg[:2] in [":-", ":+"]:
msg = msg[2:]
elif msg[:1] == ":":
msg = msg[1:]
ctx.emit_print("Channel Message", nickname,
start_color + msg + end_color)
return xchat.EAT_ALL
return xchat.EAT_NONE
xchat.hook_server("PRIVMSG", privmsg_cb)
xchat.prnt("%s %s loaded" % (__module_name__, __module_version__))
|