Beispiel #1
0
def NowPlaying(word,word_eol,userdata):
	msg = now_playing_message
	if len(word) > 1: msg = word[1]+" "+msg.split(" ",1)[1]

	songData = None
	for x in players:
		if x.playing():
			songData = x.song()
			break
		#endif
	#endfor

	if songData:
		msgs = bsection.split(msg)
		msg = ""
		for i in range(len(msgs)):
			if i%2 == 0: # replace with "" if non existent
				msg += psection.sub((lambda m: songData[m.group(2)] if m.group(2) in songData else ""),msgs[i])
			else:
				try: msg += psection.sub(r'\1s',msgs[i]) % songData
				except KeyError: pass
			#endif
		#endfor
		xchat.command(msg)
	else:
		xchat.prnt("Not playing anything")
	#endif

	return xchat.EAT_XCHAT
def SetMessage(word,word_eol,userdata):
	global now_playing_message
	if word[1] == "now_playing_message":
		if len(word_eol) > 2: # Set
			now_playing_message = word_eol[2]
			xchat.prnt("%s set to: %s" % (word[1],word_eol[2]))
		else:
			dots = 29-len(word[1])
			xchat.prnt(word[1]+"\00318"+("."*dots)+"\00319:\x0f "+now_playing_message)
		#endif
		return xchat.EAT_XCHAT
	#endif

	return xchat.EAT_NONE
Beispiel #3
0
		# Display mode
		xchat.prnt("now_playing_message..........: " + now_playing_message)
		return
	#endif

	if word[1] == "now_playing_message":
		if len(word_eol) > 2: # Set
			now_playing_message = word_eol[2]
			xchat.prnt("%s set to: %s" % (word[1],word_eol[2]))
		else:
			dots = 29-len(word[1])
			xchat.prnt(word[1]+"\00318"+("."*dots)+"\00319:\x0f "+now_playing_message)
		#endif
		return xchat.EAT_XCHAT
	#endif

	return xchat.EAT_NONE
#enddef

def SaveMessage(userdata):
	f = open(settingsLoc,"w")
	f.write(now_playing_message)
	f.close()
#enddef

xchat.hook_command("np",NowPlaying)
xchat.hook_command("set",SetMessage)
xchat.hook_unload(SaveMessage)
xchat.prnt("Loaded %s version %s." % (__module_name__,__module_version__))