From c1e63d96abf7117ba5e86b2df4f9e081758b1719 Mon Sep 17 00:00:00 2001 From: Andreas Demmelbauer Date: Wed, 4 Apr 2018 15:10:13 -0700 Subject: [PATCH] add time delay between toots --- config-example.json | 1 + tootbot.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config-example.json b/config-example.json index 670cd9f..71cd81f 100644 --- a/config-example.json +++ b/config-example.json @@ -16,6 +16,7 @@ }, "settings": { "days": 1, + "delay": 5, "dryrun": true, "databasefilepath": "tootbot.db" } diff --git a/tootbot.py b/tootbot.py index 3176776..c48e414 100755 --- a/tootbot.py +++ b/tootbot.py @@ -7,7 +7,8 @@ import requests import re import sqlite3 import html2text -from datetime import datetime, date, time, timedelta +import time +from datetime import datetime, date, timedelta @@ -34,6 +35,7 @@ soupuser = config['sources']['soup']['user'] dryrun = config['settings']['dryrun'] days = config['settings']['days'] +delay = config['settings']['delay'] # sqlite db to store processed tweets (and corresponding toots ids) @@ -157,9 +159,10 @@ for p in reversed(t.entries): print('database execution failed.') print('p.id: ', p.id) print('toot.id: ', toot.id) - else: print('Dryrun: not posting toot and not adding it to database') + print('waiting %s seconds ...' % delay) + time.sleep(delay) print('------------------------') @@ -287,5 +290,6 @@ for p in reversed(s.entries): print( '--> ', p.id, ' posted!') else: print('Dryrun: not posting toot and not adding it to database') - + print('waiting %s seconds ...' % delay) + time.sleep(delay) print('------------------------')