XChat plugin to monitor channels
Sometimes you want to monitor a low activity channel while doing something else. This plugin uses GNOME’s notifications to show you a notification of each message in the channel.
Save this as watch.py and put it in ~/.xchat2/
# Copyright 2007 Rory McCann
# Released under the GNU GPL v3 or later
# Configuration options go here
notification_title = "Message in %(channel)s"
notification_text = "<%(nick)s> %(message)s"
# End of configuration options.
__module_name__ = "WatchChannel"
__module_version__ = "1.0"
__module_description__ = "Watches a channel for new messages"
import xchat, pynotify
# This is empty at the start obviously, but it will contain network name and
# then channel name tuples.
channels_to_watch = set()
def watch_channel(word, word_eol, userdata):
global channels_to_watch
channels_to_watch.add((xchat.get_info("network"), xchat.get_info("channel")))
xchat.prnt("You are now watching %s. You are now watching a total of %d channels" % (xchat.get_info("channel"), len(channels_to_watch)) )
return xchat.EAT_ALL
def unwatch_channel(word, word_eol, userdata):
global channels_to_watch
tuple = (xchat.get_info("network"), xchat.get_info("channel"))
if tuple in channels_to_watch:
channels_to_watch.remove(tuple)
xchat.prnt("You are no longer watching %s" % (xchat.get_info("channel")))
return xchat.EAT_ALL
def message_recieved(word, word_eol, userdata):
global channels_to_watch, notification_title, notification_text
#print "channels to watch:", str(channels_to_watch)
network, channel = xchat.get_info("network"), xchat.get_info("channel")
nick, message = word[0], word[1]
if nick[0:2] == 'x032':
# Occasionally there are 3 characters at the front, this will remove them. I don't know why they are there.
nick = nick[3:]
details = {'channel':channel, 'message':message, 'nick':nick}
if (network,channel) in channels_to_watch:
n = pynotify.Notification(notification_title % details, notification_text % details, "file:///usr/share/pixmaps/xchat.png")
n.show()
return xchat.EAT_NONE
pynotify.init("Channel watcher")
xchat.hook_command("watch", watch_channel)
xchat.hook_command("unwatch", unwatch_channel)
xchat.hook_print("Your Message", message_recieved)
xchat.hook_print("Channel Message", message_recieved)
print __module_name__ + " version " + __module_version__ + " loaded"
July 28th, 2008 at 4:18 pm
celebrex…
fda celebrex…