Skip to content
Extraits de code Groupes Projets
Valider 389a40bc rédigé par Bastien Le Querrec's avatar Bastien Le Querrec
Parcourir les fichiers

RAAspotter: ajoute un suffixe aux pouets

parent 568e4c0c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -66,6 +66,7 @@ class RAAspotter:
self.smtp_configured = False
self.mastodon = None
self.mastodon_prefix = ''
self.mastodon_suffix = ''
self.update_user_agent(user_agent)
......@@ -73,20 +74,23 @@ class RAAspotter:
f.write('')
f.close()
def configure_mastodon(self, access_token, instance, mastodon_prefix):
def configure_mastodon(self, access_token, instance, mastodon_prefix, mastodon_suffix):
if (not access_token == "") and (not instance == ""):
self.mastodon = Mastodon(
access_token=access_token,
api_base_url=instance
)
self.mastodon_prefix = mastodon_prefix
self.mastodon_suffix = mastodon_suffix
def mastodon_toot(self, content):
if self.mastodon:
toot = content
if not self.mastodon_prefix == '':
self.mastodon.toot(f"{self.mastodon_prefix}\n\n{content}")
else:
self.mastodon.toot(f"{content}")
toot = f"{self.mastodon_prefix}\n\n{toot}"
if not self.mastodon_suffix == '':
toot = f"{toot}\n\n{self.mastodon_suffix}"
self.mastodon.toot(toot)
def enable_tor(self, max_requests=0):
proxies = {
......
......@@ -101,5 +101,5 @@ raa_spotter.not_before = __NOT_BEFORE
raa_spotter.configure_mailer(__SMTP_HOSTNAME, __SMTP_USERNAME, __SMTP_PASSWORD, __SMTP_PORT,
__SMTP_STARTTLS, __SMTP_SSL, __EMAIL_FROM, __EMAIL_TO,
'[RAAspotter] [Préfecture de police de Paris] Nouveaux éléments trouvés')
raa_spotter.configure_mastodon(__MASTODON_ACCESS_TOKEN, __MASTODON_INSTANCE, '[Préfecture de police de Paris]')
raa_spotter.configure_mastodon(__MASTODON_ACCESS_TOKEN, __MASTODON_INSTANCE, '[Préfecture de police de Paris]', '#ppparis')
raa_spotter.get_raa(__KEYWORDS)
......@@ -101,5 +101,5 @@ raa_spotter.not_before = __NOT_BEFORE
raa_spotter.configure_mailer(__SMTP_HOSTNAME, __SMTP_USERNAME, __SMTP_PASSWORD, __SMTP_PORT,
__SMTP_STARTTLS, __SMTP_SSL, __EMAIL_FROM, __EMAIL_TO,
'[RAAspotter] [Préfecture des Bouches-du-Rhône] Nouveaux éléments trouvés')
raa_spotter.configure_mastodon(__MASTODON_ACCESS_TOKEN, __MASTODON_INSTANCE, '[Préfecture des Bouches-du-Rhône]')
raa_spotter.configure_mastodon(__MASTODON_ACCESS_TOKEN, __MASTODON_INSTANCE, '[Préfecture des Bouches-du-Rhône]', '#pref13')
raa_spotter.get_raa(__KEYWORDS)
......@@ -101,5 +101,5 @@ raa_spotter.not_before = __NOT_BEFORE
raa_spotter.configure_mailer(__SMTP_HOSTNAME, __SMTP_USERNAME, __SMTP_PASSWORD, __SMTP_PORT,
__SMTP_STARTTLS, __SMTP_SSL, __EMAIL_FROM, __EMAIL_TO,
'[RAAspotter] [Préfecture d\'Ille-et-Vilaine] Nouveaux éléments trouvés')
raa_spotter.configure_mastodon(__MASTODON_ACCESS_TOKEN, __MASTODON_INSTANCE, '[Préfecture d\'Ille-et-Vilaine]')
raa_spotter.configure_mastodon(__MASTODON_ACCESS_TOKEN, __MASTODON_INSTANCE, '[Préfecture d\'Ille-et-Vilaine]', '#pref35')
raa_spotter.get_raa(__KEYWORDS)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter