#!/usr/bin/python import sys,socket,string,random,os,md5,time HOST = "irc.tddirc.net" PORT = 6667 NICK = "pozi_python" ALTERNATENICK = "pozi_python1" IDENT = "pozi_python" REALNAME = "pozi_python" OWNER1 = "~pozican@127.0.0.1" OWNER = '~pozican@cpe-75-82-91-44.socal.res.rr.com' CHANNELINIT = "#hackerthreads" VERSION = "0.6.26" ATTNCHAR = "!" readbuffer = "" join = 0 nick = 0 msgstart = 3 rrbegin = 0 shooter = 1 silent = 0 debug = 0 oper = 0 devoiced = 0 # # ### Function definitions ### # # def gethostname(var): hostname = var[0] hostname = hostname.split('!') hostname = hostname[1] return hostname def getusername(var): username = var[0].split('!')[0] if username[0] == ':': username = username[1:] else: username = username return username def gettype(var): type = var[2] if var[2] == CHANNELINIT: return 'public' else: return type def getsrc(var): src = var[2] return src def getmsg(bitch,int): try: msg = [bitch[int]] for i in range(4, len(bitch)): msg.append(bitch[i]) return msg except IndexError: return 0 def gethouse(): a = random.randint(0,82) housephrase = ['"I\'m world famous now. Press won\'t leave me alone." - Human Error','"Did you give an angry Cuban my home number?" - Human Error', '"The patient\'s husband prefers her not dead." - Human Error', '"How come God gets credit whenever something good happens? Where was he when her heart stopped?" - Human Error ', '"The kid\'s not a clich\xe9. Anybody can get in a fight after losing. It takes real creativity to beat up someone you just beat." - The Jerk', '"You are one evil, cunning woman. It\'s a massive turn on." - The Jerk', '"Arrogance has to be earned. Tell me what you\'ve done to earn yours." - The Jerk', '"Personally, I can\'t believe I had the same three employees for three years." - Resignation', '"He can\'t ignore the blood because it\'s a minority, can he, Foreman?" - Resignation', 'Wilson: "Oh God, she\'s 26." House: "But with the wisdom of a much younger woman." -Resignation', '"Ha! Nothing like a dead patient to send you back to your choir boy roots." - Family', '"The only value of that trust is that you can manipulate them." - Family', '"That was awesome. I gotta start pretending to care." - Family', '"Loss of free will. I like it. Maybe we can get Thomas Aquinas in for a consult." - House Training', '"First, \'Hector does go rug\' is a lame anagram. Want a better one for Gregory House? \'Huge ego, sorry.\'" - House Training', '"If you need absolution, go to a priest. Or give alms to the poor." - House Training', '"I asked you what two plus two equals and a day later you tell me, \'Not twenty-five.\'" - Act YourAge', '"Some idiot gave me two tickets for a play tonight. Saved his life. Apparently worth $186." - Act Your Age', '"Never is just reven spelled backwards." - Act Your Age', '"Panty hamster get a spin on its wheel?" - Act Your Age ', '"It may have been short, but it had girth." - Airborne', '"Good news is all the pilots are red meat men. Although I was kinda looking forward to landing this puppy myself." - Airborne', '"Happensoften in high anxiety situation, especially to women. Now it sounds sexist, butscience says you\'re weak and soft. What can I do?" - Airborne', '"Personally, I don\'t get what\'s so hard about making Scarlett Johansson look pretty." - Fetal Position', '"Mom\'s body is like an intricate German metro system. All the trains run on time." - Fetal Position', '"No, Cameron had concerns. Chase just agreed with her because he didn\'t want to lose his all access pass to her love rug." - Fetal Position', '"Even fetuses lie." - Fetal Position', '"I can play the harmonica with my nose, make a penny comeout of a child\'s ear, or any other orifice for that matter, and given the right circumstances bring two women to simultaneous ecstasy." - Top Secret','"And find out the truth about who he\'s been dating. No way a Marine goes a year without getting some blood on his bayonet." - Top Secret', '"Better be careful. I have a full bladder and I\'m not afraid to use it." - Top Secret', '"Just because it\'s inexplicted doesn\'t mean it\'s inexplicable." - Half Wit', '"Sorry. Didn\'t mean to offend your specialty." - Half Wit\n','\n', '"Dude can\'t button a shirt. How much more damage are we really talking about?" - Half Wit', '"If you\'re considering grabbing my ass, don\'t start anything you can\'t finish." - Half Wit', '"Could have left the scarf at home and just told him you\'d be wearing a look of desperation." - Insensitive', '"I was curious. Since I\'m not a cat, that\'s not dangerous." - Insensitive', '"Oh my God. You\'re not wearing a bra." - Insensitive', '"The only thing I hate more than a thief is a crippled thief." - Needle in a Haystack', '"Hey, you can\'t yell at a guy in a wheelchair." - Needle in a Haystack', '"You guys are still thinking like doctors when you should be thinking like plumbers. Come on, I wanna see some butt crack." - Needle in a Haystack', '"My life is just one horror after another." - Needle ina Haystack ', 'Cuddy: "Is that Vicodin?"\n', 'House: "Breath mint. Thought you were going to kiss me." - One Day, One Room', '"You\'ve never seen an after school special? Dawson\'s Creek? How do you get to thirty and not know about condoms?" - One Day, One Room', '"If we were to care about every person suffering on this planet, life would shut down." - One Day, One Room', '"If you called to see the design of my prison tats, they\'re still at R&D." - Words and Deeds', '"When I lead the big patient rebellion, Voldemort here is the first to go." - Words and Deeds', '"Thanks. I was running short on platitudes. You can leave now." - Words and Deeds', '"I told you never to call me when I\'m on trial." - Words and Deeds', 'Tritter: "Merry Christmas." House: "Happy go to hell." - Merry Little Christmas', '"I thought I\'d get your theories, mock them, then embrace my own. The usual." - Merry Little Christmas', '"Can we forget my vices and get back tomy virtues." - Merry Little Christmas', '"This thing won me second place in the clinic\'s weekly \'Weirdest thing pulled out of an orifice\' contest." - Finding Judas', '"If I\'m in a buttload of pain, I need a buttload of pills." - Finding Judas', '"Good thing you failed to become a mom because you suck at it!" - Finding Judas', '"Party of Five! Powerful stuff. The OC of its day." - Whac-A-Mole', 'Cameron:"You okay?" House:"Hurt my shoulder playing fantasy football." - Whac-A-Mole', '"Okay, fine. I\'ll father your child. But first you gotta write me a Vicodin prescription. Just so I can get through the foreplay." - Whac-A-Mole', '"There are reports out of South Africa about a pill that\'d temporarily revive someone in a vegetative state. We\'ve all seen Awakenings. It made me cry. I wanna cry." - Son of Coma Guy', '"Everything\'s conditional. You just can\'t always anticipate the conditions." - Son of Coma Guy', '"Quick, what\'s the status? I gotta get back to our sleeper before he goes looking for the orgasmatron." - Son of Coma Guy', '"Deep inside, Wilson believes that if he cares enough, he\'ll never have to die." - Son of Coma Guy', '"Is Salma Hayek from Mexico or Spain?" - Que Sera Sera', '"Kids these days. Got no respect for other people\'s property." - Que Sera Sera', '"It\'s probably her mom. I bet she\'s huge. She is from the Midwest. Since when do you eat beets?" - Que Sera Sera', '"You get married at twenty, you\'re going to be shocked who you\'re living with at thirty." - Fools For Love', '"Sorry. I already met this month\'s quota of useless tests for stubborn idiots." - Fools For Love', '"Twenty-year olds fall in and out of love more often than they change their oil filters. Which they should do more often." - Fools For Love ', 'Foreman: "I had a date last night. She screamed too. You think we should spend a hundred thousand dollars testing her?" House: "Of course not. This isn\'t a veterinary hospital. Zing!" - Lines in the Sand', '"Go up his rear and get a smear.Which reminds me, kinda feel like a bagel." - Lines in the Sand', 'House: "After that look, I\'m feeling a little frisky and looks like you\'re up." Cuddy: "I\'m ovulating. Let\'s go." House: "The frisky, it went away." - Lines in the Sand', '"Take this four times a day. And stay off airplanes. They\'re flying cesspools." - Informed Consent ', '"Somehow I just can\'t imagine you taking a Jell-O shot." - Informed Consent ', '"I try to kill him, you\'re mad. I don\'t kill him, you\'re mad." - Informed Consent','"I\'m a cripple, remember? Accommodations must be made." - Informed Consent', '"Is this an intervention? You\'re a little late, since I\'m not using drugs anymore. I am, however, still hooked on phonics." - Cane and Able ', '"The kid is having nightmares. Only happen at night. It\'s right there in thename." - Cane and Able ', '"She was being metaphorical. She was tryingto sound like me. I have no idea what you meant, but I could smell what the Rock was cooking." - Cane and Able ', '"Why don\'t I have high-def in my office? I\'m a department head." -Cane and Able ', 'Cuddy: "Why did you." House: "Why does a dog lick its workplace-acceptable euphemism for testicles?"- Meaning', '"Oh, I stuck that primo! How rad am I?" - Meaning', 'Cameron: "You\'re lucky he didn\'t die." House: "I\'m lucky? He\'s the one who didn\'t die." - Meaning'] return housephrase[a] def getinsult(): a = random.randint(1,3) if a == 1: b = random.randint(0,17) insultphrase = ["cock-gobbling sperm-gargling mongoloid","cum-belching fuck-weasel","Your father is a crack-addled monkey-buggering slut","Scat munching prick","Felching moseph-loving whore","The mere sight of you repulses me more than the fetid stench of semen on a young child's breath","Donkey-banging father-fucker","Your idea of a hot date is rooting around the dumpsters at the back of abortion clinics.","mother-fucker","piece of shit","pigmolesting fucker","Die.","Kill yourself","Slit your wrists","Fat shit","Are you always this stupid; or is this some kind of stupid season?","cock-faced spunk-gargling monkey-rapis","You have an ass like a clown's pockets."] return insultphrase[b] if a == 2: animalrand = random.randint(0,22) sexactrand = random.randint(0,9) insultrand = random.randint(0,11) animal = ['bear','muppet','midget','lion','donkey','dog','cat','toad','fish','eel','shark','kangaroo','iguana','porcupine','baboon','zebra','tiger','gazelle','panda','koala','squid','horse','moseph'] sexact = ['fucking','sucking','raping','humping','blowing','loving','testi-grabbing','groping','fondling','riding'] insult = ['cunt','muppet','chode','bitch','jackass','asshat','whore','mother-fucker','fudgepacker','dumbass','fuckhead','ass-burglar','pig molester'] fullinsult = animal[animalrand] + " " + sexact[sexactrand] + " " + insult[insultrand] return fullinsult if a == 3: rand1 = random.randint(0,49) rand2 = random.randint(0,49) rand3 = random.randint(0,49) phrase1 = ['artless','bawdy','beslubbering','bootless','churlish','clouted','cockered','craven','currish','dankish','dissembling','droning','errant','fawning','fobbing','frothy','froward','gleeking','goatish','gorbellied','impertinent','infectious','jarring','loggerheaded','lumpish','mammering','mangled','mewling','paunchy','pribbling','puking','puny','qualling','rank','reeky','roguish','ruttish','saucy','spleeny','spongy','surly','tottering','unmuzzled','vain','venomed','villainous','warped','wayward','weedy','yeasty'] phrase2 = ['base-court','bat-fowling','beef-witted','beetle-headed','boil-brained','clapper-clawed','clay-brained','common-kissing','crook-pated','dismal-dreaming','dizzy-eyed','doghearted','dread-bolted','earth-vexing','elf-skinned','fat-kidneyed','fen-sucked','flap-mouthed','fly-bitten','folly-fallen','fool-born','full-gorged','guts-griping','half-faced','hasty-witted','hedge-born','hell-hated','idle-headed','ill-breeding','ill-nurtured','knotty-pated','milk-livered','motley-minded','onion-eyed','plume-plucked','pottle-deep','pox-marked','reeling-ripe','rough-hewn','rude-growing','rump-fed','shard-borne','sheep-biting','spur-galled','swag-bellied','tardy-gaited','tickle-brained','toad-spotted','urchin-snouted','weather-bitten'] phrase3 = ['apple-john','baggage','barnacle','bladder','boar-pig','bugbear','bum-bailey','canker-blossom','clack-dish','clotpole','codpiece','coxcomb','death-token','dewberry','flap-dragon','flax-wench','flirt-gill','foot-licker','fustilarian','giglet','gudgeon','haggard','harpy','hedge-pig','horn-beast','hugger-mugger','joithead','lewdster','lout','maggot-pie','malt-work','mammet','measle','minnow','miscreant','moldwarp','mumble-news','nut-hook','pigeon-egg','pignut','pumpion','puttock','ratsbane','scut','skainsmate','strumpet','varlet','vassal','wagtail','whey-face'] fullinsult = phrase1[rand1] + " " + phrase2[rand2] + " " + phrase3[rand3] return fullinsult def say(fuckme): s.send("PRIVMSG %s :%s \r\n" % (CHANNELINIT, ' '.join(fuckme[1:]))) print '<' + NICK + '> ' + ' '.join(fuckme[1:]) def publicmsg(msg): s.send("PRIVMSG %s :%s \r\n" % (CHANNELINIT, msg)) print "<"+NICK+"> " + msg def privmsg(username,msg): s.send("PRIVMSG %s :%s\r\n" % (username,msg)) def connectserver(HOST,PORT): s.connect((HOST, PORT)) s.send("NICK %s\r\n" % NICK) s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME)) def doaction(action): action = action[1:] s.send("PRIVMSG %s :\001ACTION %s \001\r\n" % (CHANNELINIT, ' '.join(action))) print '* ' + NICK + ' ' + ' '.join(action) def kick(username, reason): s.send("KICK %s %s :%s\r\n" % (CHANNELINIT, username, reason)) print '-!- %s was kicked from %s by %s [%s]' % (username, CHANNELINIT, NICK, reason) def joinchannel(channel): s.send("JOIN %s \r\n" % channel) # # ### Actual connection ### # # s=socket.socket( ) connectserver(HOST,PORT) # # ### This loop is to continue reading everything the server sends ### # # while 1: readbuffer=readbuffer+s.recv(1024) temp=string.split(readbuffer, "\n") readbuffer=temp.pop() for line in temp: line=string.rstrip(line) line=string.split(line) if(line[0]=="PING"): s.send("PONG %s\r\n" % line[1]) if join==0: joinchannel(CHANNELINIT) join = 1 # # ### Enable Debug Software ### # # if debug == 1: print line # # ### Time to start printing normal chat ### # # if getmsg(line,3) != 0 and line[1] == 'PRIVMSG' and line[3] != ':\x01ACTION': if gettype(line) == 'public': kablah = "<" + getusername(line) + "> " a = [kablah] print ''.join(a) + ' '.join(getmsg(line,3))[1:] # # ### Tell whoever to Die ### # # word = line for i in range(3,len(line)): if word[i] == ':' + NICK + ':' or word[i] == ':' + NICK or word[i] == NICK or word[i] == NICK+':' or word[i] == NICK + "," or word[i] == ":" + NICK + "," or word[i] == ":" + NICK + "!" or word[i] == NICK + "!": if getusername(line) != 'ShockX' and silent != 1: insult = getinsult() publicmsg("%s: %s" % (getusername(line), insult)) break # # ### Version info ### # # if line[3] == ':' + ATTNCHAR + 'version' and silent != 1: publicmsg(VERSION) # # ### MD5 function ### # # if line[3] == ':' + ATTNCHAR + 'md5' and silent != 1: md5msg = [line[3]] for i in range(4,len(line)): md5msg.append(line[i]) md5msg = ' '.join(md5msg[1:]) m = md5.new() m.update(md5msg) md5string = m.hexdigest() publicmsg("%s: %s" % (getusername(line),md5string)) # # ### Fortune feature - Linux only ### # # if line[3] == ':' + ATTNCHAR + 'fortune' and silent != 1: fortune = ' '.join(os.popen('fortune').readlines()).replace('\n',' ').replace('\t',' ') while len(fortune) >= 410: fortune = ' '.join(os.popen('fortune').readlines()).replace('\n',' ').replace('\t',' ') publicmsg("%s: %s" % (getusername(line), fortune)) # # ### House Quotes ### # # if line[3] == ':' + ATTNCHAR + 'house' and silent != 1: publicmsg('%s: %s' % (getusername(line),gethouse())) # # ### Russian Roulette ### # # if line[3] == ':' + ATTNCHAR + 'rr' and silent != 1: try: if line[4] == 'begin' or line[4] == 'start' and rrbegin == 0: starter = getusername(line) rrbegin = 1 rrbeginarray = ['Russian Roulette - Prepare to die.','Russian Roulette - Some cunt has a death wish','Russian Roulette - You fucking fuck, shoot already','Russian Roulette - Pussy, pull the trigger','Russian Roulette - Are you feeling lucky? Well, are ya?','Russian Roulette - Fine, simply playing with your own life'] lenarray = len(rrbeginarray) - 1 publicmsg(rrbeginarray[random.randint(0,lenarray)]) luckyguy = random.randint(1,6) shooter = 1 if line[4] == 'stop' and rrbegin == 1: rrbegin = 0 publicmsg('Russian Roulette ended. Fucking pussies.') if line[4] == 'shoot': if rrbegin == 1: if shooter == luckyguy: bangarray = ['Bang - You just got it up the ass','Bang - Told you you\'d die you sorry fuck','Bang - Don\'t cry, it\'s just a game','Bang - Thud, that was loud, you must be more fat than moseph','Bang - wtf did you expect to happen?','Bang - Must have fucking hurt... That\'ll teach ya','Bang - Hope it was painful.','Bang - O boo hoo, go cry to your mom','Bang - Wow you just got fucked','Bang - By the way, I fucked your mom last night','Bang - I call the pathetic fuck\'s server'] lenarray = len(bangarray) - 1 publicmsg(getusername(line) + ': ' + bangarray[random.randint(0,lenarray)]) rrbegin = 0 else: safearray = ['*CLICK* - It\'s coming, just wait your fucking turn','*CLICK* - You live to die another day','*CLICK* - Lucky pos','*CLICK* - Dude, the bathroom is right over there','*CLICK* - You whore, man up and take that pussy face off','*CLICK* - It\'s coming','*CLICK* - I think that was a misfire you ass-chode','*CLICK* - Cheating death once more eh?','*CLICK* - Don\'t get your hopes up, your turn is coming soon'] lenarray = len(safearray) - 1 publicmsg(getusername(line) + ': ' + safearray[random.randint(0,lenarray)]) shooter = shooter + 1 else: publicmsg('Start the game first dumbass.') except IndexError: publicmsg('Usage: %srr {begin|shoot|stop}' % ATTNCHAR) else: # # ### Handle Private Messages ### # # kablah = "<" + getusername(line) + "> " a = [kablah,gettype(line)] print ''.join(a) + ' '.join(getmsg(line,3)) if line[3] == ':cmd' or line[3] ==':help' or line[3] == ':commands' or line[3] == ':command': privmsg(getusername(line),'current unauthorized user commands are: %sfortune || %srr {begin|stop|shoot} || %sversion || %smd5 {string}' % (ATTNCHAR, ATTNCHAR, ATTNCHAR, ATTNCHAR)) # # ### Accept commands from pozican ### # # try: if gettype(line) == NICK and gethostname(line) == OWNER: if line[3] == ':insult': try: insult = getinsult() publicmsg('%s: %s' % (line[4],insult)) except IndexError: s.send("PRIVMSG %s :Syntax error. Usage: /msg %s [person to insult]\r\n" % (getusername(),NICK)) elif line[3] ==':say': say(getmsg(line,3)) elif line[3] ==':nick': try: print 'Nick Change from %s to %s' % (NICK, line[4]) NICK = line[4] s.send("NICK %s\r\n" % NICK) except IndexError: s.send("PRIVMSG %s :Syntax error. Usage: /msg %s [new nick]\r\n" % (getusername(line), NICK)) elif line[3] == ':quit': s.close() break elif line[3] == ':join': try: joinchannel(line[4]) except IndexError: privmsg(getusername(line),'Syntax error: Usage: /msg %s join [channel] \r\n' %(NICK)) elif line[3] == ':silent': try: if line[4] == 'on': silent = 1 publicmsg('silence mode activated') if line[4] == 'off': silent = 0 publicmsg('silence mode de-activated') except IndexError: privmsg(getusername(line),'Syntax Error. Usage: /msg %s silent {on|off}\r\n' % NICK) elif line[3] == ':action': doaction(getmsg(line,3)) elif line[3] == ':chgattn': try: ATTNCHAR = line[4] publicmsg('Attention char changed to: %s' % ATTNCHAR) except IndexError: privmsg(getusername(line),'Syntax Error. Usage: /msg %s chgattn {Attention Char}' % NICK) elif line[3] == ':kick': try: user = line[4] reason = getmsg(line,3)[1:] kick(user, ' '.join(reason)) except IndexError: privmsg(getusername(line), 'Syntax Error. Usage: /msg %s kick {username reason}') elif line[3] == ':debug': try: if line[4] == 'on': debug = 1 publicmsg('debug mode activated') if line[4] == 'off': debug= 0 publicmsg('debug mode de-activated') except IndexError: privmsg(getusername(line),'Syntax Error. Usage: /msg %s debug {on|off}' % (NICK)) elif line[3] == ':commands' or ':help': privmsg(getusername(line),'Current commands for authorized users are: insult {name} || say {msg} || nick {new nick} || quit || silent {on|off} || action {action} || debug {on|off} || chgattn {new attention char}') else: s.send("PRIVMSG %s :Command '%s' not found.\r\n" % (getusername(line),line[3][1:])) except IndexError: print 'must be the server' # # ### Start Formatting the info ### # # elif line[1] == 'JOIN': print '-!- %s [%s] has joined %s' % (getusername(line),gethostname(line),CHANNELINIT) insult = getinsult() publicmsg("%s: %s" % (getusername(line),insult)) elif line[1] == 'PART' or line[1] == 'QUIT': if len(line) >= 3: msg = [line[2]] for i in range(3, len(line)): msg.append(line[i]) msg = ' '.join(msg)[1:] print '-!- %s [%s] has quit %s [%s]' % (getusername(line),gethostname(line),CHANNELINIT,msg) else: print '-!- %s [%s] has quit %s []' % (getusername(line),gethostname(line),CHANNELINIT) elif line[1] == 'NICK': print '-!- %s is now known as %s' % (getusername(line), line[2][1:]) elif line[1] == 'MODE': if len(line) < 4: print '-!- mode/%s [%s %s] by %s' % (CHANNELINIT, line[3], line[4], getusername(line)) if len(line) > 4: print '-!- mode/%s [%s]' % (CHANNELINIT, line[3]) # # ### Rejoin if De-Voiced ### # # if len(line) > 3: if line[3] == '-v' and line[4] == NICK: s.send('PART %s demmit\r\n' % CHANNELINIT) join = 0 joinchannel(CHANNELINIT) join = 1 devoiced = 1 if line[3] == '+v' and line[4] == NICK and devoiced == 1 and getusername(line) == 'ShockX': publicmsg('I will *not* be silenced!') devoiced = 0 elif line[0] == 'PING': print time.strftime("%a %b %d, %Y %-I:%M:%S %p",time.localtime(time.time())) elif line[1] == 'KICK': print '-!- %s was kicked from %s by %s [%s]' % (line[3], line[2], getusername(line),' '.join(getmsg(line,4))) # # ### Rejoin After Kick ### # # if len(line) >= 3: if line[3] == NICK: join = 0 elif line[1] == 'NOTICE': print '-%s(%s)-%s' % (getusername(line),gethostname(line),' '.join(getmsg(line,3))) elif line[1] == 'PRIVMSG' and len(line)>=3 and line[3] == ':\x01ACTION': print '* %s %s' % (getusername(line), ' '.join(getmsg(line,3))[9:]) else: msg = ' '.join(line) if msg[0] == ':': print ' '.join(line)[1:] else: print ' '.join(line)