Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.16 KB | None | 0 0
  1. import socket
  2. import sys
  3. import urllib2
  4. from BeautifulSoup import BeautifulSoup
  5.  
  6. server = "irc.76chan.tk"       #settings
  7. channel = "#76chan"
  8. botnick = "somebot"
  9.  
  10. irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
  11. print "connecting to:"+server
  12. irc.connect((server, 6667))
  13. text=irc.recv(2040)
  14. irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n")
  15. if text.find('PING') != -1:                          #check if 'PING' is found
  16.     irc.send('PONG ' + text.split() [1] + '\r\n')  
  17.                                                          #connects to the server
  18. irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n") #user authentication
  19. irc.send("NICK "+ botnick +"\n")     #auth
  20. irc.send("JOIN "+ channel +"\n")
  21.  
  22. while 1:    #puts it in a loop
  23.     text=irc.recv(2040)  #receive the text
  24.     print text   #print text to console
  25.  
  26.     if text.find('PING') != -1:                          #check if 'PING' is found
  27.         irc.send('PONG ' + text.split() [1] + '\r\n') #returnes 'PONG' back to the server (prevents pinging out!)
  28.  
  29.     irc.send("JOIN "+ channel +"\n")
  30.  
  31.     if text.find(':!hi') != -1:
  32.         i = text.split("!")
  33.         nig = i[0].strip(':')
  34.         irc.send('PRIVMSG '+channel+' :Hello '+str(nig)+'! \r\n')
  35.  
  36.  
  37.     if text.find(':PING') != -1:
  38.         irc.send('PRIVMSG '+channel+' :PONG!!!11!one! \r\n')
  39.  
  40.  
  41.     if text.find(':!k') != -1:
  42.         i = text.split("!")
  43.         nig = i[0].strip(':')
  44.         irc.send('KICK '+channel+' '+nig+' \r\n')
  45.  
  46.     if text.find(':!commands') != -1 or text.find(':!help') != -1:
  47.         irc.send('PRIVMSG '+channel+' : !hi makes the bot say Hello <yournick> \r\n')
  48.         irc.send('PRIVMSG '+channel+' : PING makes the bot say PONG!!!11!one! \r\n')
  49.         irc.send('PRIVMSG '+channel+' : !k gets you kicked \r\n')
  50.         irc.send('PRIVMSG '+channel+' : !garrett tells you all about some dead kid \r\n')
  51.         irc.send('PRIVMSG '+channel+' : Posting a YouTube link will have the bot say the title. \r\n')
  52.  
  53.     if text.find('JOIN :'+channel) != -1:
  54.         i = text.split("!")
  55.         nig = i[0].strip(':')
  56.         irc.send('PRIVMSG '+channel+' :AYYYY '+nig+' \r\n')
  57.  
  58.     if text.find('!garrett') != -1:
  59.         irc.send('PRIVMSG '+channel+' :http://members.jacksonville.com/news/crime/2014-07-21/story/every-parents-worst-nightmare-teen-sneaks-out-dies-late-night-mandarin \r\n')
  60.         irc.send('PRIVMSG '+channel+' :https://twitter.com/GarrettSchaub/status/332686127284776960 \r\n')
  61.         irc.send('PRIVMSG '+channel+' :https://twitter.com/garrett_schaub/status/387757164527620097/photo/1 \r\n')
  62.         irc.send('PRIVMSG '+channel+' :https://twitter.com/garrett_schaub/status/401494360321040384/photo/1 \r\n')
  63.         irc.send('PRIVMSG '+channel+' :https://twitter.com/garrett_schaub/status/482353916961505280/photo/1 \r\n')
  64.  
  65.     if text.find(':http://youtube.com') != -1 or text.find(':https://youtube.com') != -1 or text.find(':http://www.youtube.com') != -1 or text.find(':https://www.youtube.com') != -1:
  66.         i = text.split(' :')
  67.         nig = i[1].strip(' :')
  68.         nog = BeautifulSoup(urllib2.urlopen(nig))
  69.         neg = str(nog.title)
  70.         nag = neg.strip('</title>')
  71.         nug = nag[:-9]
  72.         irc.send('PRIVMSG '+channel+' :1,0You0,4Tube '+str(nug) +' \r\n')
  73.         #irc.send('PRIVMSG '+channel+' :'+nig+' \r\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement