Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import requests
- from willie.module import commands, interval
- archives = requests.get('https://raw.githubusercontent.com/MayhemYDG/archives.json/master/archives.json').json()
- last_post = {}
- search_query = '?text=removethis|removethis|removethis'
- # change text to whatever you are searching for, filename is filename, image hash is simply image - change 'removethis' for desires search queries
- channel = '#removethis'
- # remove for desired channel input
- for archive in archives:
- if archive['software'] != 'foolfuuka':
- continue
- for board in archive['boards']:
- last_post[board] = 0
- start = False
- @interval(60)
- def check(bot):
- global last_post, start
- for archive in archives:
- if archive['software'] != 'foolfuuka':
- continue
- proto = 'https' if archive['https'] else 'http'
- print 'checking %s' % archive['domain']
- try:
- resp = requests.get('%s://%s/_/api/chan/search/%s' % (proto, archive['domain'], search_query))
- except:
- resp = requests.get('http://%s/_/api/chan/search/%s' % (archive['domain'], search_query))
- for board in archive['boards']:
- for post in reversed(resp.json()[0]['posts']):
- if 'board' not in post: # stupid archives
- continue
- if post['board']['shortname'] != board:
- continue
- if int(post['num']) > last_post[board]:
- last_post[board] = int(post['num'])
- if start:
- bot.msg(channel, '%s: %s %s://%s/%s/thread/%s#%s' %
- (post['name'], post['comment'][:200], proto, archive['domain'], board, post['thread_num'], post['num']))
- start = True
- print last_post
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement