From 8c6c279c2bff2713d74a58045f863aa53dac7ea5 Mon Sep 17 00:00:00 2001
From: cquest <cquest@openstreetmap.fr>
Date: Tue, 25 Jun 2019 15:05:16 +0200
Subject: [PATCH] =?UTF-8?q?ajout=20delay=20pour=20envoi=20diff=C3=A9r?=
 =?UTF-8?q?=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 tootbot.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tootbot.py b/tootbot.py
index a62953b..053e4f8 100755
--- a/tootbot.py
+++ b/tootbot.py
@@ -9,7 +9,7 @@ from mastodon import Mastodon
 import requests
 
 if len(sys.argv) < 4:
-    print("Usage: python3 tootbot.py twitter_account mastodon_login mastodon_passwd mastodon_instance [max_days [footer_tags]]")  # noqa
+    print("Usage: python3 tootbot.py twitter_account mastodon_login mastodon_passwd mastodon_instance [max_days [footer_tags [delay]]]")  # noqa
     sys.exit(1)
 
 # sqlite db to store processed tweets (and corresponding toots ids)
@@ -33,6 +33,12 @@ if len(sys.argv) > 6:
 else:
     tags = None
 
+if len(sys.argv) > 7:
+    delay = int(sys.argv[7])
+else:
+    delay = 0
+
+
 source = sys.argv[1]
 mastodon = sys.argv[2]
 passwd = sys.argv[3]
@@ -53,8 +59,8 @@ for t in reversed(d.entries):
     dt = t.published_parsed
     age = datetime.now()-datetime(dt.tm_year, dt.tm_mon, dt.tm_mday,
                                   dt.tm_hour, dt.tm_min, dt.tm_sec)
-    # process only unprocessed tweets less than 1 day old
-    if last is None and age < timedelta(days=days):
+    # process only unprocessed tweets less than 1 day old, after delay
+    if last is None and age < timedelta(days=days) and age > timedelta(days=delay):
         if mastodon_api is None:
             # Create application if it does not exist
             if not os.path.isfile(instance+'.secret'):
-- 
GitLab