Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ircutils import bot, start_all
- import os
- import subprocess
- import urllib
- import base64
- class yapib(bot.SimpleBot):
- def __init__(self, nick):
- bot.SimpleBot.__init__(self, nick)
- self.nick = "NFO_Bot"
- self.real_name = "Based on http://github.com/Transfusion/yapib"
- self.user = "cutie"
- self["any"].add_handler(self.print_line)
- self.verbose = False
- def print_line(self, client, event):
- kwds = {
- "cmd": event.command,
- "src": event.source,
- "tgt": event.target,
- "params": event.params
- }
- print "[{cmd}] s={src!r} t={tgt!r} p={params}".format(**kwds)
- def on_channel_message(self, event):
- tx = event.message.split()
- rx = tx[0].upper()
- params = tx[1:]
- if event.message.startswith("!searchnfo"):
- new_list = []
- newlist = []
- newlist1 = []
- htmlSource = urllib.urlopen("http://nforush.net/scene-release/dupecheck-result.html?name="+params[0]+"&sys=0&submit=SEARCH").read(200000)
- for chunk in htmlSource.lower().split('href=')[1:]:
- indexes = [i for i in [chunk.find('"',1),chunk.find('>'),chunk.find(' ')] if i>-1]
- new_list.append(chunk[:min(indexes)])
- i = 0
- for i in range(i, len(new_list), 1):
- if new_list[i].startswith('"nfo.html?rls='):
- u = new_list[i].replace('&', '&')+"&view=image"
- newlist.append(u)
- else: pass
- for item in newlist: #remove duplicates
- if item not in newlist1:
- newlist1.append(item)
- else: pass
- a = 0
- for a in range(a, len(newlist1), 1):
- self.send_message(event.target, str(newlist1[a][1:]))# or send to IRC, or whatever...
- print newlist1[a][1:]
- else: pass
- if event.message.startswith("!fetchnfo"):
- new_list = []
- newlist = []
- newlist1 = []
- htmlSource = urllib.urlopen("http://nforush.net/"+params[0]).read(200000)
- for chunk in htmlSource.lower().split('img src=')[1:]:
- indexes = [i for i in [chunk.find('"',1),chunk.find('>'),chunk.find(' ')] if i>-1]
- new_list.append(chunk[:min(indexes)])
- new_list.append(chunk[:min(indexes)])
- i = 0
- for i in range(i, len(new_list), 1):
- if new_list[i].startswith('"nfo.php?release='):
- u = new_list[i].replace('&', '&')
- newlist.append(u)
- else: pass
- for item in newlist: #remove duplicates
- if item not in newlist1:
- newlist1.append(item)
- else: pass
- a = 0
- for a in range(a, len(newlist1), 1):
- z = "http://nforush.net/"+newlist1[a][1:]# or send to IRC, or whatever...
- a = str(base64.urlsafe_b64encode(os.urandom(30)))
- urllib.urlretrieve(z, a+".png")
- os.system('convert '+a+'.png'+' -background black -flatten /var/www/temp/'+a+'.png')
- self.send_message(event.target, 'Generated NFO: '+'http://base.node3.hpc.tw:81/temp/'+a+'.png')
- if __name__ == "__main__":
- instance = yapib("NFO_Bot")
- instance.connect("main.node2.hpc.tw", port=60124, channel="#opg")
- start_all()
Add Comment
Please, Sign In to add comment