0 Members and 1 Guest are viewing this topic.
__module_name__ = "IrmageBoard"__module_version__ = "0.2.0"__module_description__ = "Liek a real imageboard guies (without the images!!!1)"import xchat, string, re, random, yamlfrom urllib import urlopenglobal myFilterymlFilter = urlopen("http://xvicario.us/irmageboard/filters.yml")myFilter = yaml.load(ymlFilter)ymlFilter.close()print "\0034",__module_name__, __module_version__, "has been loaded\003"def greenText(word, word_eol, userdata): print "EXECUTING greenText()" if word_eol[0].find('>'): return xchat.EAT_NONE print "FOUND NOTHING!" else: xchat.command(" ".join(["msg", xchat.get_info("channel"), ''.join(["3",word_eol[0]])])) print "FOUND SOMETIHNG!" return xchat.EAT_ALLdef filters(word, word_eol, userdata): newString = word_eol[0] for k, v in myFilter.iteritems(): if k in newString: tempColor = random.randrange(0,16,1) tempBack = random.randrange(0,16,1) tempReplace = re.compile(k, re.IGNORECASE) newString = tempReplace.sub(v, newString) newString = "".join(["\003",str(tempColor),",",str(tempBack),newString,"\003"]) xchat.command(" ".join(["msg", xchat.get_info("channel"), newString])) return xchat.EAT_ALLxchat.hook_command("", greenText)xchat.hook_command("", filters)
__module_name__ = "IrmageBoard"__module_version__ = "0.2.0"__module_description__ = "Like a real imageboard guies (without the images!!1)"import stringimport reimport randomimport yamlimport xchatimport urllib2global myFilter #Do you really need to use globals? They ain't recommendedymlFilter = urllib2.urlopen("http://xvicario.us/irmageboard/filters.yml")myFilter = yaml.load(ymlFilter)ymlFilter.close()print "\0034 %s %s has been loaded\003" % (__module_name__, __module_version__)def greenText(word, word_eol, userdata): """TODO Docstring for greenText()""" print "EXECUTING greenText()" if word_eol[0].find('>'): return xchat.EAT_NONE print "FOUND NOTHING!" else: xchat.command(" ".join(["msg", xchat.get_info("channel"), ''.join(["3",word_eol[0]])])) print "FOUND SOMETHING!" return xchat.EAT_ALLdef filters(word, word_eol, userdata): """Filters a word""" newString = word_eol[0] for k, v in myFilter.iteritems(): if k in newString: tempColor = random.randrange(0, 16, 1) tempBack = random.randrange(0, 16, 1) tempReplace = re.compile(k, re.IGNORECASE) newString = tempReplace.sub(v, newString) newString = "".join(["\003", str(tempColor), ", ", str(tempBack), newString,"\003"]) xchat.command(" ".join(["msg", xchat.get_info("channel"), newString])) return xchat.EAT_ALL
It does the same thing edit: you can actually see my debugging code "EXECUTING greenText()" etc lol that stuff never shows up, so i can safely say it doesn't execute. I also disabled the urlopen and the code then worked...
That is how you are supposed to intercept outgoing messages... See the filters() function. that does ALMOST the same thing.edit: Somehow it was in my last two lines. I switched the order of them (so the filter got hooked first, then the greenText) and it works... Idk why...
__module_name__ = "IrmageBoard"__module_version__ = "0.2.0"__module_description__ = "Liek a real imageboard guies (without the images!!!1)"import xchat, string, re, random, yamlfrom urllib import urlopenglobal myFilterymlFilter = urlopen("http://xvicario.us/irmageboard/filters.yml")myFilter = yaml.load(ymlFilter)ymlFilter.close()print "\0034",__module_name__, __module_version__, "has been loaded\003"def greenText(word, word_eol, userdata): print "EXECUTING greenText()" if word_eol[0].find('>'): return xchat.EAT_NONE print "FOUND NOTHING!" else: xchat.command(" ".join(["msg", xchat.get_info("channel"), ''.join(["3",word_eol[0]])])) print "FOUND SOMETIHNG!" return xchat.EAT_ALLdef filters(word, word_eol, userdata): newString = word_eol[0] for k, v in myFilter.iteritems(): if k in newString: tempColor = random.randrange(0,16,1) tempBack = random.randrange(0,16,1) tempReplace = re.compile(k, re.IGNORECASE) newString = tempReplace.sub(v, newString) newString = "".join(["\003",str(tempColor),",",str(tempBack),newString,"\003"]) xchat.command(" ".join(["msg", xchat.get_info("channel"), newString])) greenText(word, word_eol, userdata) # Call that 2nd function! return xchat.EAT_ALL # May not be necessary, since the greenText function also returns this too... although... # Maybe I'm a bit wrong in how it returns. If the 2nd function doesn't kick out of the plugin, simply do # ret = greenText(word, word_eol, userdata) # return retxchat.hook_command("", filters)
Its kinda funny because just switching them fixed it. Both things work now. This is my third script for XChat. Its really fun doing this lol.