Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I STOLE MOST PART FROM ELSEWHERE AND MODDED IT TO FIT MY NEEDS
- import os
- import urllib2
- import random
- import re
- import socket
- import thread
- import time
- from HTMLParser import HTMLParser
- from Tkinter import Tk
- #-- IRC Setup --#
- def sendmsg(msg, channel):
- irc.send ( 'PRIVMSG ' + channel + ' :' + msg + '\r\n' )
- def sendcmd(cmd, data):
- irc.send ( cmd + ' ' + data + '\r\n' )
- def pingpong(data):
- if data.find ( 'PING' ) != -1:
- irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
- def pongping(network, data):
- sendcmd('PING', network)
- if 'PING' in data:
- return True
- print 'Connected to ' + network
- else:
- return False
- def rcvdata(data):
- global channel
- if data.find ( 'PRIVMSG' ) != -1:
- nick = data.split ( '!' ) [ 0 ].replace ( ':', '' )
- message = ':'.join ( data.split ( ':' ) [ 2: ] )
- print nick + ':', message.rstrip("\n\r")
- if message.find ('!start') == 0:
- #sendmsg("Starting senbot at " + message[7:], channel)
- thread.start_new_thread(fgetse, (message[7:],))
- if message.find ('!quit') == 0:
- sendcmd('QUIT', message[5:])
- #---------------#
- class getlinks(HTMLParser): #Parses html to find links
- def handle_starttag(self, tag, attrs): #Handles any opening tag
- global nurl
- if tag == 'a': #If the tag is a link
- for atr in attrs:
- if atr[0] == 'href': #Get it's href sttribute
- if atr[1][0:7] == 'http://' or atr[1][0:8] == 'https://': #Make sure it's http of https
- if random.randrange(0, 8) == 1: #There's a one in nine chance
- nurl = atr[1] #That this it will go to this link next
- class striphtml(HTMLParser): #Strips html tags from html data. Ripped from stackoverflow
- def __init__(self):
- self.reset()
- self.fed = []
- def handle_data(self, d): #if it's data (not a tag)
- self.fed.append(d) #add it to fed[].
- def get_data(self): #return fed[]
- return ''.join(self.fed)
- def striptags(html): #Get html without all that annoying markup!
- s = striphtml() #call the parser
- s.feed(html)
- return s.get_data() #Get the data
- def getse(text): #Gets a sentence form 'text'
- sens = re.findall(r'[A-Z][A-Za-z ,]+[!.?]', text) #Starts with a capital, has 1 or more letters, commas, or spaces, and ends in a !, . , or ?
- if len(sens) != 0: #If the
- rtn = sens[len(sens)-random.randrange(0, len(sens))]
- if len(rtn) > 20:
- return rtn
- def fgetse(surl):
- global nurl
- global channel
- nurl = surl
- user_agent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' #Set as googlebot to get access to forums/etc.
- headers = { 'User-Agent' : user_agent }
- while True:
- try:
- response = urllib2.urlopen(nurl) #Open link
- html = response.read()
- linkp = getlinks()
- linkp.feed(html)
- #print nurl
- sen = getse(striptags(html))
- if sen != None:
- print 'Wrote: ' + sen
- sendmsg(sen, channel)
- except Exception,e: #Oh noes!
- nurl = surl #Go back to lulzy place
- nurl = ''
- network = 'irc.darkode.com'#irc.darkode.com'#raw_input('What network do you want to join?\n')
- channel = '#lizardsquad'#raw_input('What channel do you want to join?\n')
- nurl = raw_input('What website will you start spamming?')
- print 'Generating nick\n'
- nick = os.urandom(16).encode('hex')[:12] #raw_input('Name?\n')#wololo'
- print 'New nick: ' + nick
- #r = Tk()
- #r.withdraw()
- #r.clipboard_clear()
- #r.clipboard_append('/msg ' + nick + ' !start ' + nurl)
- #r.destroy()
- port = 6667
- connected = False
- irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
- irc.connect ( ( network, port ) )
- sendcmd('NICK', nick)
- sendcmd( 'USER', nick + ' foo bar ' + nick )
- conn = False
- while True:
- data = irc.recv(4096)
- pingpong(data)
- if connected:
- if not conn:
- sendcmd('PRIVMSG', 'NickServ IDENTIFY mypassword')
- data = irc.recv ( 4096 )
- while data.find(nick) == -1:
- time.sleep(1)
- sendcmd('JOIN', channel)
- sendcmd('/mode', nick + ' +B')
- #sendmsg('ready!', channel)
- print 'ready! nick is ' + nick
- thread.start_new_thread(fgetse, (nurl,))
- conn = True
- else:
- thread.start_new_thread(rcvdata, (data,))
- else:
- connected = pongping(network, data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement