From 389a40bccd1e2669df74b83ce64edf1d98ebe24f Mon Sep 17 00:00:00 2001
From: Bastien Le Querrec <blq@laquadrature.net>
Date: Mon, 18 Mar 2024 18:41:02 +0100
Subject: [PATCH] RAAspotter: ajoute un suffixe aux pouets

---
 RAAspotter.py | 12 ++++++++----
 ppparis.py    |  2 +-
 pref13.py     |  2 +-
 pref35.py     |  2 +-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/RAAspotter.py b/RAAspotter.py
index dbed759..1842a9f 100644
--- a/RAAspotter.py
+++ b/RAAspotter.py
@@ -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 = {
diff --git a/ppparis.py b/ppparis.py
index d938e6d..78e324f 100755
--- a/ppparis.py
+++ b/ppparis.py
@@ -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)
diff --git a/pref13.py b/pref13.py
index 309d11d..54fca2b 100755
--- a/pref13.py
+++ b/pref13.py
@@ -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)
diff --git a/pref35.py b/pref35.py
index 4e9603c..d89db8b 100755
--- a/pref35.py
+++ b/pref35.py
@@ -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)
-- 
GitLab