diff --git a/bot.py b/bot.py index 775bbee9c04503dca33a26947b2b1e9c3de307be..8f67e88f31c508e643d86499b3a38c8d7c7bf0ad 100755 --- a/bot.py +++ b/bot.py @@ -29,13 +29,13 @@ class Bot(Client): self.send(Message('BOT :' + to_send), thread_id=thread_id, thread_type=thread_type) self.trigger_double_mots(message_object.text, thread_id, thread_type) - Bot.shitpostbot5000() + self.shitpostbot5000() - @classmethod def shitpostbot5000(self): for chan in Bot.shitpostbot: if Bot.shitpostbot[chan][0].get_status(): if Bot.shitpostbot[chan][0].get_latest(): + print('Shitpostbot5000 a dégoté une nouvelle image...') self.sendLocalImage(Bot.shitpostbot[chan][0].get_out(), thread_id=chan, thread_type=Bot.shitpostbot[chan][1]) def tests(self, texte, thread_id, thread_type, author_id, channel=''): diff --git a/useless/shitpostbot5k.py b/useless/shitpostbot5k.py index 5236ef87a73f57c7e9395a17279dc955eba89938..d1ecc7b3f1eaef81191c4c0888445aa0b1d1b6c5 100755 --- a/useless/shitpostbot5k.py +++ b/useless/shitpostbot5k.py @@ -7,15 +7,16 @@ import datetime class Shitpostbot5000(object): - def __init__(self, out="shitpostbot5k_latest.jpg"): + def __init__(self, url='https://www.facebook.com/shitpostbot5k/feed', out="shitpostbot5k_latest.jpg"): self.state = False self.image = '' self.date = datetime.datetime.now() self.out = out + self.url = url def get_latest(self): if datetime.datetime.now() > self.date + datetime.timedelta(minutes=30): - html = urlopen('https://www.facebook.com/shitpostbot5k/feed') + html = urlopen(self.url) bs = BeautifulSoup(html, 'html.parser') image = bs.find_all('img', {'src': re.compile('.jpg')})[-1]['src'] if image != self.image: