## init stuff __module_name__ = "PyQuote" __module_version__ = "really unstable" __module_description__ = "made for kuht.it" import xchat,md5 from random import choice from random import shuffle from socket import gethostbyname ## configuration stuff channel = ["#kuht"] quotefile = "c:/documents and settings/viper/desktop/quote.data.py" ## engine qfile = open(quotefile,'r+') def givequote(): xchat.command('msg ' + channel[0] + ' [QUOTE]: ' + str(choice(qfile.readlines())).strip()) qfile.seek(0) def addquote(string,nick): noop = qfile.readlines() qfile.write(string + "\n") qfile.seek(0) xchat.command('notice ' + nick + ' Quote Addato! [python quoting system by viper]') def google(key): xchat.command("msg %s [G]: http://www.google.com/search?q=%s" %(channel[0],"%20".join(key.split()))) def googleimg(key): xchat.command("msg %s [G]: http://images.google.com/images?q=%s" %(channel[0],"%20".join(key.split()))) def dns(host): xchat.command("msg %s [DNS]: %s risolto in %s" %( channel[0],host,gethostbyname(host) ) ) def sparkize(frase): st = '' f = '' for x in frase.split(): e = list(x) shuffle(e) for a in e: st = st + a st = st + ' ' xchat.command("msg " + channel[0] + ' ' + '[Sparkizer]: ' + st) def md5hash(stringa): xchat.command("msg " + channel[0] + ' ' + '[MD5 Hash]: ' + stringa + ' => ' + md5.new(stringa).hexdigest()) def getdata(word,word_eol,userdata): if word[2] in channel: if word[3] == ":!quote": givequote() return xchat.EAT_NONE elif word[3] == ":!addquote": addquote(word_eol[4],word[0][1:word[0].find("!")]) return xchat.EAT_NONE elif word[3] == ":!google": google(word_eol[4]) return xchat.EAT_NONE elif word[3] == ":!img": googleimg(word_eol[4]) return xchat.EAT_NONE elif word[3] == ":!dns": dns(word[4]) return xchat.EAT_NONE elif word[3] == ":!sparkize": sparkize(word_eol[4]) return xchat.EAT_NONE elif word[3] == ":!md5": md5hash(word_eol[4]) return xchat.EAT_NONE else: return xchat.EAT_NONE else: return xchat.EAT_NONE ## runtime xchat.hook_server("PRIVMSG", getdata)