Skip to content
Extraits de code Groupes Projets
Valider 785327ec rédigé par Loïc Wikle DUBARD's avatar Loïc Wikle DUBARD
Parcourir les fichiers

shitpostbot fix not a classmethod anymore

parent 5b3d04bd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -29,13 +29,13 @@ class Bot(Client): ...@@ -29,13 +29,13 @@ class Bot(Client):
self.send(Message('BOT :' + to_send), thread_id=thread_id, thread_type=thread_type) 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) self.trigger_double_mots(message_object.text, thread_id, thread_type)
Bot.shitpostbot5000() self.shitpostbot5000()
@classmethod
def shitpostbot5000(self): def shitpostbot5000(self):
for chan in Bot.shitpostbot: for chan in Bot.shitpostbot:
if Bot.shitpostbot[chan][0].get_status(): if Bot.shitpostbot[chan][0].get_status():
if Bot.shitpostbot[chan][0].get_latest(): 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]) 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=''): def tests(self, texte, thread_id, thread_type, author_id, channel=''):
......
...@@ -7,15 +7,16 @@ import datetime ...@@ -7,15 +7,16 @@ import datetime
class Shitpostbot5000(object): 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.state = False
self.image = '' self.image = ''
self.date = datetime.datetime.now() self.date = datetime.datetime.now()
self.out = out self.out = out
self.url = url
def get_latest(self): def get_latest(self):
if datetime.datetime.now() > self.date + datetime.timedelta(minutes=30): 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') bs = BeautifulSoup(html, 'html.parser')
image = bs.find_all('img', {'src': re.compile('.jpg')})[-1]['src'] image = bs.find_all('img', {'src': re.compile('.jpg')})[-1]['src']
if image != self.image: if image != self.image:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter