Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # PreBOT V1.0
- # Built By El3ct71k
- # PreDB.Me
- import socket, string, urllib2, threading, time
- import xml.etree.ElementTree as etree
- login = {'server':'irc.efnet.nl','port':'6667','nickname':'PREBOT','idenet':'PREBOT','realname':'Carolina'}
- channels = {'#staff':''}
- categories = ['Movies-SD','Movies-HD','TV-SD','TV-HD', 'GAMES-PC']
- color = {'black':chr(3)+"1",'blue':chr(3)+"12",'gray':chr(3)+"14",'red':chr(3)+"4",'green':chr(3)+"3",'orange':chr(3)+"7"}
- lastpre = {}
- def LoginIRC():
- irc=socket.socket()
- irc.connect((login['server'], int(login['port'])))
- irc.send("NICK %s\r\n" % login['nickname'])
- irc.send("USER %s %s:%s bla :%s\r\n" % (login['idenet'], login['server'], login['port'], login['realname']))
- for chan,key in channels.iteritems():
- irc.send("JOIN %s %s\r\n" % (chan, key))
- while True:
- readbuffer=""
- readbuffer=readbuffer+irc.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"):
- irc.send("PONG %s\r\n" % line[1])
- mynick = line[0].split('!')[0].replace(':', '')
- PreBOT(irc)
- if line[1].startswith('PRIVMSG'):
- if(line[3].lower()==':!pre'):
- threading.Thread(target=PrebotSEARCH, args=(line, irc)).start()
- if(mynick.lower() == 'cyb3rw0rm'):
- if(line[3].lower()==":!command"):
- Management(irc,line)
- elif(line[3].lower()==":!addpre"):
- try:
- try:
- chan = line[4]+" "+line[5]
- channels[line[4]] = line[5]
- except:
- chan = line[4]
- channels[line[4]] = ''
- irc.send("JOIN %s\r\n" % (chan))
- except:
- irc.send ("PRIVMSG %s : %s \r\n" % (line[2], color['red']+"Error"+color['gray']+"["+color['blue']+"!"+color['gray']+"]"+color['orange']+" try again.. syntax: !addpre #chan key"))
- elif(line[3].lower()==":!delpre"):
- try:
- del channels[line[4]]
- irc.send("PART %s\r\n" % line[4])
- except:
- irc.send ("PRIVMSG %s : %s \r\n" % (line[2], color['red']+"Error"+color['gray']+"["+color['blue']+"!"+color['gray']+"]"+color['orange']+" try again.. syntax: !delpre #chan"))
- elif(line[3].lower()==":!listpre"):
- irc.send ("PRIVMSG %s : %s \r\n" % (line[2], color['blue']+"My Channels:"+color['blue']))
- for listchan in channels:
- irc.send ("PRIVMSG %s : %s \r\n" % (line[2], " "+color['green']+listchan+color['green']))
- def PreBOT(irc):
- for type in categories:
- root = etree.XML(urllib2.urlopen(urllib2.Request('http://predb.me/?cats='+type.lower()+'&rss=1')).read())
- key = type.replace('-', '')
- try:
- lastpre[key]
- except KeyError:
- lastpre[key]= list(list(root.iter("item"))[1])[0].text
- for pre in list(root.iter("item")):
- pre = list(pre)
- if(list(list(root.iter("item"))[0])[0].text != lastpre[key]):
- for chan in channels:
- irc.send ("PRIVMSG %s : %s \r\n" % (chan, color['gray']+" [ "+color['orange']+"PREDB"+color['gray']+" ] [ "+color['red']+type+color['gray']+" ] [ "+color['black']+pre[0].text+color['gray']+" ] [ "+color['green']+pre[1].text+color['gray']+" ] "+color['gray']))
- lastpre[key] = pre[0].text
- else:
- break
- def PrebotSEARCH(line,irc):
- id = int(3)
- search = str('')
- mynick = line[0].split('!')
- mynick = mynick[0].replace(':', '')
- while True:
- id +=1
- try:
- search +=line[id]+" "
- except:
- break
- irc.send ("PRIVMSG %s : %s \r\n" % (mynick, color['blue']+"Results of "+color['blue']+color['red']+search+color['red']))
- root = etree.XML(urllib2.urlopen(urllib2.Request('http://predb.me/?search='+str(search[0:-1])+'&rss=1')).read())
- try:
- list(root.iter("item"))[0]
- for pre in reversed(list(root.iter("item"))):
- pre = list(pre)
- irc.send ("PRIVMSG %s : %s \r\n" % (mynick, color['gray']+" [ "+color['orange']+"PREDB"+color['gray']+" ] [ "+color['blue']+"Results of "+color['red']+search[0:-1]+color['gray']+" ] [ "+color['black']+pre[0].text+color['gray']+" ] [ "+color['green']+pre[1].text+color['gray']+" ] "+color['gray']))
- except:
- irc.send ("PRIVMSG %s : Not found :( \r\n" % mynick)
- def Management(irc,line):
- command = ''
- num = int(4)
- while True:
- try:
- command += str(line[num]+" ")
- num += 1
- except:
- break
- irc.send("%s \r\n" % command[0:-1].replace('msg', 'PRIVMSG'))
- if __name__ == '__main__':
- try:
- LoginIRC()
- except socket.error:
- threading.Timer(660, LoginIRC).start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement