All pastes #335021 Raw Edit

biisXchatTalkScript

public python v1 · immutable
·published 2007-02-01 01:37 UTC
rendered paste body
# Talk.py# An X-Chat Python Script by Maulsel# What it does: Colors names for roleplay.# Tested on: X-Chat Aqua 0.16.0# You may modify this code as long as you keep the copyright info.# Copyright: Script is Public Domain. Originally Created by Maulsel.import xchat, pickle, os.path__module_name__ = "Talk"__module_version__ = "0.2"__module_description__ = "Colors names for roleplay."xchat.prnt("Loading Talk script...")# let's define some stuffconfigFile = 'Talk.cfg'null = ''data = []null2 = '(lp0\n.'# let's get the stored data out of the fileif (os.path.isfile(configFile)):	xchat.prnt("Trying to open config file...")	f = open(configFile, 'r')	xchat.prnt("Loading contents...")	cont = f.read()	if (cont != null):		if (cont != null2):			temp = pickle.loads(cont)			data = temp			xchat.prnt("Loaded.")	else:		xchat.prnt("No content saved to load.")	f.close()else:	xchat.prnt("Creating config file...")	f = open(configFile, 'w')	f.close()	xchat.prnt("Created.")		def dotalk(word, word_eol, userdata):	lookfor = word[1].capitalize()	for i in data:		for x in i:			if x == lookfor:				name = i[0]				color = i[1]				bgcolor = i[2]				break	xchat.command("SAY " + color + "," + bgcolor + "(" + name + ") " + word_eol[2])	return xchat.EAT_ALL	def setcolor(word, word_eol, userdata):	gotit = 0	lookfor = word[1].capitalize()	for i in data:		for x in i:				if x == lookfor:					i[1] = word[2]					i[2] = word[3]					gotit = 1					break	if gotit == 0:		data.append([word[1].capitalize(), word[2], word[3]])	xchat.command("ECHO Set colors for " + word[1].capitalize() + ". Preview: " + word[2] + "," + word[3] + "(" + word[1].capitalize() + ")")	return xchat.EAT_ALL	def dotest(word, word_eol, userdata):	xchat.command("ECHO " + data)	return xchat.EAT_ALL	def unload_cb(userdata):	xchat.prnt("Saving data...")	f = open(configFile, 'w')	pickle.dump(data, f)	f.close()	xchat.prnt("Saved.")	xchat.prnt("Unloaded Talk.")xchat.hook_unload(unload_cb)xchat.hook_command("setcolors", setcolor, help="/setcolors name color bgcolor")xchat.hook_command("talk", dotalk, help="/talk name What to say")xchat.hook_command("test", dotest, help="/test")xchat.prnt("Loaded Talk script.")