Ver código fonte

add time delay between toots

master
Andreas Demmelbauer 6 anos atrás
pai
commit
c1e63d96ab
2 arquivos alterados com 8 adições e 3 exclusões
  1. +1
    -0
      config-example.json
  2. +7
    -3
      tootbot.py

+ 1
- 0
config-example.json Ver arquivo

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


+ 7
- 3
tootbot.py Ver arquivo

@@ -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('------------------------')

Carregando…
Cancelar
Salvar