"""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 " __copyright__ = "Copyright 2005 Lars Wirzenius ." __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[^!]+)!") 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__))