0 Members and 1 Guest are viewing this topic.
<config> <irc.omnimaga.org> <Omnimaga> <greentext val="0" /> <filters val="0" /> <filter-url val="null" /> </Omnimaga> <IRP> <greentext val="1" /> <filters val="1" /> <filter-url val="http://xvicario.us/irmageboard/irp.yml" /> </IRP> </irc.omnimaga.org></config>
__module_name__ = "IrmageBoard"__module_version__ = "0.5.5"__module_description__ = "Liek a real imageboard guies (without the images!!!1)"tinyVersion = 55import xchat, string, re, random, yaml, sys, os, StringIOimport xml.etree.ElementTree as ElementTreefrom urllib2 import urlopenymlFilter = urlopen("http://xvicario.us/irmageboard/filters.yml")myFilter = yaml.load(ymlFilter)ymlFilter.close()configPath = "".join([re.sub('\IrmageBoard.py$', '', os.path.realpath(__file__)),"irmageconfig.xml"])myConfig = open(configPath)myCfg = ElementTree.parse(myConfig)myConfig.close()print "\0034>>>>>",__module_name__, __module_version__, "has been loaded <<<<<\003"def greenText(word, word_eol, userdata): if word_eol[0].find('>'): return xchat.EAT_NONE else: xchat.command(" ".join(["msg", xchat.get_info("channel"), ''.join(["3",word_eol[0]])])) return xchat.EAT_ALLdef filters(word, word_eol, userdata): newString = word_eol[0] for k, v in myFilter.iteritems(): tempColor = random.randrange(0,16,1) tempBack = random.randrange(0,16,1) while (tempColor == tempBack): tempColor = random.randrange(0,16,1) tempBack = random.randrange(0,16,1) tempReplace = re.compile(k, re.IGNORECASE) newString = tempReplace.sub("".join(["\003", str(tempColor), ",", str(tempBack), v, "\003"]), newString) xchat.command(" ".join(["msg", xchat.get_info("channel"), newString])) return xchat.EAT_ALLdef irmageCommand(word, word_eol, userdata): try: if word[1] == "filters": if word[2] == "on": filterHook = xchat.hook_command("", filters) print "\0034Filters are now on! GO AT IT!\003" if word[2] == "off": xchat.unhook(filterHook) print "\0034You turned filters off :(\003" if word[1] == "log": log = urlopen("http://xvicario.us/irmageboard/log.txt") print log.read() log.close() if word[1] == "about": print __module_name__," v",__module_version__,"\nWritten by Brian J Maurer (XVicario.us, contact at [email protected])\nThis plugin adds features to XChat like an imageboard's \"\0033>greentext\003\" and filters (like when you type \"jew\" it turns into \"\0035,3Steve Jobs\003\". Many more features are to come :D" if word[1] == "update": if word[2] == "filter": print "\0034Updating Filters...\003" global ymlFilter ymlFilter = urlopen("http://xvicario.us/irmageboard/filters.yml") global myFilter myFilter = yaml.load(ymlFilter) ymlFilter.close() print "\0034Filters are Updated!\003" """ if word[2] == "script": myversion = urlopen("http://xvicario.us/irmageboard/version") myversion = int(myversion.read()) if (myversion == tinyVersion): print "\0034NO UPDATE FOUND!\003" elif (myversion > tinyVersion): print "\0034UPDATE FOUND!\003" print "\0034Downloading Update...\003" update = urlopen("http://xvicario.us/irmageboard/update") update = update.read() irmageBoard = open("IrmageBoard.py","w") irmageBoard.write(update) irmageBoard.close() print "\0034Update Successful!\003" else: print "\0034ARE YOU FROM THE FUTURE!?\003" """ if word[1] == "dump": global myCfg myCfg2 = ElementTree.tostring(myCfg) print myCfg print xchat.get_info("server") if word[1] == "add": if word[2] == "server": myConfig = open("".join([re.sub('\IrmageBoard.py$', '', os.path.realpath(configPath))]),"r+") ircfg = myConfig.read() ircfg = ElementTree.XML(ircfg) newServer = ElementTree.Element(xchat.get_info("server")) ircfg.append(newServer) cfgFile = StringIO.StringIO() ircfg = ElementTree.tostring(ircfg) print type(ircfg), ircfg ircfg = cfgFile.write(ircfg) ircfg = ElementTree.parse(ircfg) ircfg.write(myConfig) myConfig.close() except IndexError: print "\0034Welcome to the IrmageBoard Plugin! For a brief help type '/help irmage'.\003" return xchat.EAT_ALL def facepalm(word, word_eol, userdata): xchat.command("ME facepalms at " + word_eol[1]) xchat.EAT_ALL# Hook the commands :Dxchat.hook_command("IRMAGE", irmageCommand, help="Usage:\n/irmage filters <on/off> -- Turn the filters on or off\n/irmage log -- Display the changelog of the plugin (downloaded from XVicario.us)\n/irmage about -- Display an about text\n/irmage update filter -- update the list of word filters, when you load the script you will automatically have this, but if something changes when the script is loaded, just run this and you have the new filtes ;D")xchat.hook_command("", filters)xchat.hook_command("", greenText)xchat.hook_command("facepalm",facepalm)