Browse Source

add time delay between toots

master
Andreas Demmelbauer 6 years ago
parent
commit
c1e63d96ab
2 changed files with 8 additions and 3 deletions
  1. +1
    -0
      config-example.json
  2. +7
    -3
      tootbot.py

+ 1
- 0
config-example.json View File

@@ -16,6 +16,7 @@
}, },
"settings": { "settings": {
"days": 1, "days": 1,
"delay": 5,
"dryrun": true, "dryrun": true,
"databasefilepath": "tootbot.db" "databasefilepath": "tootbot.db"
} }


+ 7
- 3
tootbot.py View File

@@ -7,7 +7,8 @@ import requests
import re import re
import sqlite3 import sqlite3
import html2text 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'] dryrun = config['settings']['dryrun']
days = config['settings']['days'] days = config['settings']['days']
delay = config['settings']['delay']




# sqlite db to store processed tweets (and corresponding toots ids) # 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('database execution failed.')
print('p.id: ', p.id) print('p.id: ', p.id)
print('toot.id: ', toot.id) print('toot.id: ', toot.id)

else: else:
print('Dryrun: not posting toot and not adding it to database') print('Dryrun: not posting toot and not adding it to database')
print('waiting %s seconds ...' % delay)
time.sleep(delay)
print('------------------------') print('------------------------')




@@ -287,5 +290,6 @@ for p in reversed(s.entries):
print( '--> ', p.id, ' posted!') print( '--> ', p.id, ' posted!')
else: else:
print('Dryrun: not posting toot and not adding it to database') print('Dryrun: not posting toot and not adding it to database')

print('waiting %s seconds ...' % delay)
time.sleep(delay)
print('------------------------') print('------------------------')

Loading…
Cancel
Save