changeset 2847:7b4b8e135cb9 trunk

Add IRC+PP support.
author William Pitcock <nenolod@atheme.org>
date Tue, 19 Jun 2007 15:36:09 -0500
parents ef9446cebfcb
children 9373f9ec469d
files contrib/xchat-audacious.py
diffstat 1 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/xchat-audacious.py	Fri Jun 15 13:52:40 2007 -0500
+++ b/contrib/xchat-audacious.py	Tue Jun 19 15:36:09 2007 -0500
@@ -64,4 +64,54 @@
 xchat.hook_command("PLAY",  makeVoidCommand('Play'),    help="Begins playback.")
 xchat.hook_command("SENDTRACK", command_send, help="Syntax: /SENDTRACK <nick>\nSends the currently playing track to a user.")
 
+# IRC+PP support section
+
+# XChat is lame and does not give us a server list.
+def get_servers():
+	chanlist = xchat.get_list("channels")
+	servlist = []
+
+	for i in chanlist:
+		if i.server not in servlist:
+			servlist.append(i.server)
+
+	return servlist
+
+ignore_services = 0;
+def ignore_service_errors_cb(word, word_eol, userdata):
+	global ignore_services
+
+	if ignore_services == 1:
+		return xchat.EAT_ALL
+
+	return xchat.EAT_NONE
+
+xchat.hook_print("Notice", ignore_service_errors_cb)
+
+def unset_ignore_services(userdata=None):
+	global ignore_services
+
+	ignore_services = 0
+
+def presence_notification_dispatch(userdata=None):
+	global ignore_services
+
+	aud = get_aud()
+
+	ignore_services = 1
+	if aud:
+		pos = aud.Position()
+
+		title = aud.SongTitle(pos).encode("utf8")
+
+		slist = get_servers()
+		for i in slist:
+			ctx = xchat.find_context(i)
+
+			ctx.command("nickserv set qproperty np %s" % (title))
+
+presence_notification_dispatch()
+xchat.hook_timer(60000, presence_notification_dispatch)
+xchat.hook_timer(1000, unset_ignore_services)
+
 print "xchat-audacious $Id: xchat-audacious.py 4574 2007-05-16 07:46:17Z deitarion $ loaded"