From 785327ecc22ffc951c1d8f2ac2e6f1c36d5899f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Wikle=20DUBARD?= <loic97429@gmail.com>
Date: Tue, 20 Aug 2019 11:19:11 +0200
Subject: [PATCH] shitpostbot fix not a classmethod anymore

---
 bot.py                   | 4 ++--
 useless/shitpostbot5k.py | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/bot.py b/bot.py
index 775bbee..8f67e88 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 5236ef8..d1ecc7b 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:
-- 
GitLab