All pastes #618351 Raw Edit

Someone

public python v1 · immutable
·published 2007-07-13 22:18 UTC
rendered paste body
#!/usr/bin/env python"""bot.py - botAuthor: JonAbout: (non)"""import socketimport randomnetwork = 'irc.freenode.net'port = 6667irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )irc.connect ( ( network, port ) )irc.recv ( 4096 )irc.send ( 'NICK rbirntpython\r\n' )irc.send ( 'USER rbirntpython rbirntpython rbirntpython :Python IRC\r\n' )irc.send ( 'JOIN #chirpbot\r\n' )irc.send ( 'PRIVMSG #chirpbot :Hey everybody! My trigger is $. $help for a list of commands!\r\n' )irc.send ( 'PRIVMSG NickServ :IDENTIFY mezonah\r\n')while True:   data = irc.recv ( 4096 )   if data.find ( 'PING' ) != -1:      irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )   elif data.find ( 'PRIVMSG' ) != -1:      victim = ' '      nick = data.split ( '!' ) [ 0 ].replace ( ':', '' )      message = ':'.join ( data.split ( ':' ) [ 2: ] )      destination = ''.join ( data.split ( ':' ) [ :2 ] ).split ( ' ' ) [ -2 ]      if destination == 'rbirntpython':         destination = 'PRIVATE'      print '(', destination, ')', nick + ':', message      if nick==victim:         irc.send ( 'PRIVMSG '+ destination +' :'+message+', '+nick+'\r\n' )      if message.startswith ( 'victim ' ) and nick=='wert613':         mes_parts = message.split()         victim = mes_parts[-1]     # The action command allows people to do thing to people with things.      if message.startswith ( '$action ' ):         mes_parts = message.split()         irc.send ( 'PRIVMSG '+ destination +' :ACTION  ' +mes_parts[1]+ 's '+ mes_parts[-2] +' with a ' + mes_parts[-1] + '\r\n' )# Help gives a list of commands.      if message.startswith ( "$help" ):         irc.send ( 'PRIVMSG '+ destination +'  :Try saying hi to me in many ways, also say wow rbirntpython but dont call anyone stupid! type "rbirntpython <action> <nick> <object>" to do somehting to someone\r\n' )# Stupid, if anyone says stupid he chooses between a few answers.            if message.find ( 'stupid' )!= -1 or message.find ( 'Stupid' )!= -1:         choices = ['Thats mean ' + nick + '!','Dont say that ' + nick + '!','Noone is stupid ' + nick + '!','Thats not true ' + nick + '!']         sendChoice = choices[random.randrange(len(choices))]         irc.send ( 'PRIVMSG '+ destination +'  :' +sendChoice+ '\r\n' )	      # Wow, if anyone says wow rbirntpython he replies.      if message.find ( 'wow rbirntpython' )!= -1:         irc.send ( 'PRIVMSG '+ destination +'  :Im glad youre impressed!\r\n' )      # Leave, only authorized personnel can make rbirntpython quit.# At the moment the list contains: wert613, chirpsalot.      if message.startswith ( '$leave rbirntpython' ) and nick=='wert613':            irc.send ( 'QUIT '+ destination +'  :Yes sir, the rest of you, ILL BE BACK!.\r\n' )      elif message.startswith ( '$leave rbirntpython' ) and nick=='chirpsalot':         irc.send ( 'QUIT '+ destination +'  :Yes sir, the rest of you, ILL BE BACK!.\r\n' )		      # Hi, rbirntpython will reply t a variety of greetings.            if message.startswith ( 'hi rbirntpython') or message.startswith ( 'hello rbirntpython' ) or message.startswith ( 'yo rbirntpython' ) or message.startswith ( 'hiya rbirntpython' ) or message.startswith ( 'heya rbirntpython\r\n' ):         choices = ['Hi ' + nick + '!','Hiya ' + nick + '!','Hello ' + nick + '!','Yo ' + nick + '!']         sendChoice = choices[random.randrange(len(choices))]         irc.send ( 'PRIVMSG '+ destination +'  :'+ sendChoice +'\r\n' )            if message.startswith ( 'wassup rbirntpython' ) or message.startswith ( 'wassap rbirntpython' ) or message.startswith ( 'whats up rbirntpython' ):         irc.send ( 'PRIVMSG '+ destination +'  :Not much.\r\n' )            if message.startswith ( 'how is it going rbirntpython' ) or message.startswith ( 'hows it going rbirntpython' ) or message.startswith ( "how's it going rbirntpython" ) or message.startswith ( "how are you rbirntpython" ) or message.startswith ( "how are you, rbirntpython" ):         choices = ['Great! ' + nick + ' how about you?','Alright ' + nick + '.','Awful ' + nick + '! Im being chased by the police!','Not bad ' + nick + '.']         sendChoice = choices[random.randrange(len(choices))]         irc.send ( 'PRIVMSG '+ destination +'  :'+ sendChoice +'\r\n' )# Trigger, this command allows people to get his trigger even if they do not know what it is.            if message.startswith ( 'trigger' ) or message.startswith ( 'what is rbirntpythons trigger' ) or message.startswith ( "what's rbirntpythons trigger" ) or  message.startswith ( 'whats rbirntpythons trigger' ) or message.startswith ( "what's rbirntpython's trigger" ) or message.startswith ( "whats rbirntpython's trigger\r\n" ):         irc.send ( 'PRIVMSG ' + destination + ' :My trigger is $\r\n' )# Rbirntpython!, he will reply to an exclamation of his name.      if message.startswith ( 'rbirntpython!' ):         irc.send ( 'PRIVMSG '+ destination +'  :' + nick + '!\r\n' )# Join, only authorized personnel can make rbirntpython join a channel.# At the moment the list contains: wert613, chirpsalot.      if message.startswith ( 'rbirntpython join ' ) or message.startswith ( 'rbirntpython: join ' ) and nick=='wert613':         mes_parts = message.split()         irc.send ( 'JOIN ' +mes_parts[-1]+ ' \r\n' )      elif message.startswith ( 'rbirntpython join ' ) or message.startswith ( 'rbirntpython: join ' ) and nick=='chirpsalot':         mes_parts = message.split()         irc.send ( 'JOIN ' +mes_parts[-1]+ ' \r\n' )# Part, only authorized personnel can make rbirntpython part from a channel.# At the moment the list contains: wert613, chirpsalot.      if message.startswith ( 'rbirntpython leave ' ) or message.startswith ( 'rbirntpython: leave ' ) and nick=='wert613':         mes_parts = message.split()         irc.send ( 'PART ' +mes_parts[-1]+ ' \r\n' )      elif message.startswith ( 'rbirntpython leave ' ) or message.startswith ( 'rbirntpython: leave ' ) and nick=='chirpsalot':         mes_parts = message.split()         irc.send ( 'PART ' +mes_parts[-1]+ ' \r\n' ) # Speak, this command is beta and does not work correctly at the moment.            #if 1==1:         #raw_input('>>> ')         #user_input = raw_input('>>> ')         #irc.send ( 'PRIVMSG ' + destination + ' :' +user_input+ '\r\n' )# Op, this command is also a beta.      #if message.startswith ( 'rbirntpython op ' ) or message.startswith ( 'rbirntpython: op ' ) and nick=='wert613':         #mes_parts = message.split()         #irc.send ( 'PRIVMSG '+destination+' : /mode #chirpbots +o ' +mes_parts[-1]+ '\r\n' )# Chat privmsg, talk through him by way of private messaging.      if destination == 'PRIVATE' and nick=='wert613':         irc.send ( 'PRIVMSG #chirpbot :' +message+ '\r\n' )      elif destination == 'PRIVATE' and nick=='chirpsalot':         irc.send ( 'PRIVMSG #chirpbot :' +message+ '\r\n' )       elif destination == 'PRIVATE' and message.startswith ('say ') and nick=='wert613':         irc.send ( 'PRIVMSG #chirpbot :' +message+ ' - '+nick+'\r\n' )      elif destination == 'PRIVATE' and message.startswith ('say ') and nick=='chirpsalot':         irc.send ( 'PRIVMSG #chirpbot :' +message+ ' - '+nick+'\r\n' )      if message.startswith ( 'victim ' ) and nick=='wert613':         mes_parts = message.split()         victim = mes_parts[-1]                 if nick==victim:         irc.send ( 'PRIVMSG '+ destination +' :'+message+', '+nick+'\r\n' )