Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import sys
- import urllib2
- from BeautifulSoup import BeautifulSoup
- server = "irc.76chan.tk" #settings
- channel = "#76chan"
- botnick = "somebot"
- irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
- print "connecting to:"+server
- irc.connect((server, 6667))
- text=irc.recv(2040)
- irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n")
- if text.find('PING') != -1: #check if 'PING' is found
- irc.send('PONG ' + text.split() [1] + '\r\n')
- #connects to the server
- irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n") #user authentication
- irc.send("NICK "+ botnick +"\n") #auth
- irc.send("JOIN "+ channel +"\n")
- while 1: #puts it in a loop
- text=irc.recv(2040) #receive the text
- print text #print text to console
- if text.find('PING') != -1: #check if 'PING' is found
- irc.send('PONG ' + text.split() [1] + '\r\n') #returnes 'PONG' back to the server (prevents pinging out!)
- irc.send("JOIN "+ channel +"\n")
- if text.find(':!hi') != -1:
- i = text.split("!")
- nig = i[0].strip(':')
- irc.send('PRIVMSG '+channel+' :Hello '+str(nig)+'! \r\n')
- if text.find(':PING') != -1:
- irc.send('PRIVMSG '+channel+' :PONG!!!11!one! \r\n')
- if text.find(':!k') != -1:
- i = text.split("!")
- nig = i[0].strip(':')
- irc.send('KICK '+channel+' '+nig+' \r\n')
- if text.find(':!commands') != -1 or text.find(':!help') != -1:
- irc.send('PRIVMSG '+channel+' : !hi makes the bot say Hello <yournick> \r\n')
- irc.send('PRIVMSG '+channel+' : PING makes the bot say PONG!!!11!one! \r\n')
- irc.send('PRIVMSG '+channel+' : !k gets you kicked \r\n')
- irc.send('PRIVMSG '+channel+' : !garrett tells you all about some dead kid \r\n')
- irc.send('PRIVMSG '+channel+' : Posting a YouTube link will have the bot say the title. \r\n')
- if text.find('JOIN :'+channel) != -1:
- i = text.split("!")
- nig = i[0].strip(':')
- irc.send('PRIVMSG '+channel+' :AYYYY '+nig+' \r\n')
- if text.find('!garrett') != -1:
- 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')
- irc.send('PRIVMSG '+channel+' :https://twitter.com/GarrettSchaub/status/332686127284776960 \r\n')
- irc.send('PRIVMSG '+channel+' :https://twitter.com/garrett_schaub/status/387757164527620097/photo/1 \r\n')
- irc.send('PRIVMSG '+channel+' :https://twitter.com/garrett_schaub/status/401494360321040384/photo/1 \r\n')
- irc.send('PRIVMSG '+channel+' :https://twitter.com/garrett_schaub/status/482353916961505280/photo/1 \r\n')
- 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:
- i = text.split(' :')
- nig = i[1].strip(' :')
- nog = BeautifulSoup(urllib2.urlopen(nig))
- neg = str(nog.title)
- nag = neg.strip('</title>')
- nug = nag[:-9]
- irc.send('PRIVMSG '+channel+' :1,0You0,4Tube '+str(nug) +' \r\n')
- #irc.send('PRIVMSG '+channel+' :'+nig+' \r\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement