#!/usr/bin/env python from random import * from pyirclib import * from string import * import os import re import socket global textlist irc = Irclib('houston.tx.us.astrolink.org',6667) def initialise(): error=irc.login("hostbot",username="hostbot") error2=irc.join("#speccy", password="16384") textlist=["!host","donkeyblowjobs.com"] return error def flatten_list(intlist): string = "" for i in intlist: string += " " string += "%s" % (i) return string def extract(text): text=string.lower(text).strip() textlist=text.split(' ') flag=0 if textlist[0]=="!host" and len(textlist)>1: hostname=textlist[1] try: if re.match(r'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+',hostname)==None: hostaddr=socket.gethostbyname(hostname) else: hostaddr=socket.gethostbyaddr(hostname) except socket.gaierror: hostaddr="that name or service was not found." except socket.herror: hostaddr="that host is unknown." results=["According to my sources,",hostaddr] output=message['nickname']+": "+str(results[0])+" "+str(results[1]) irc.privmsg (target,output) elif textlist[0]=="!quit": flag=2 elif textlist[0]=="!outrun": num1=0 num2=0 while num1==num2: num1=randrange(1,15) num2=randrange(1,15) output="Loading...found %s expected %s" % (num1,num2) irc.privmsg(target,output) irc.privmsg(target,"R Tape Loading Error 0:1") return flag error=initialise() print error while 1: textlist=["!host","donkeyblowjobs.com"] message=irc.getmessage() event=message['event'] if event=='PRIVMSG': target="" if message['recpt']=='hostbot': target=message['nickname'] elif message['recpt']=="#speccy": target="#speccy" text=message['text'] flag=extract(text) if flag==2 and message['nickname']=="Graham": irc.logout ("Buh bye!") break