-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.py
42 lines (35 loc) · 909 Bytes
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import babytrump
import time
import traceback
import gpt3_light as gpt3
def run_now(baby_monitor):
infanticizer = gpt3.Infanticizer()
statuses = baby_monitor.read_stream()
for text, replyto_id in statuses:
print()
tweet = infanticizer.process(text)
if not tweet:
print("No valid tweet, skipping ", text)
continue
baby_monitor.tweet(tweet, replyto_id)
print('.',)
def run_continuously():
baby_monitor = babytrump.TwitterBabyMonitor()
errorCount = 0
while True:
try:
run_now(baby_monitor)
time.sleep(60)
except KeyboardInterrupt:
print("Safely quitting")
exit(0)
except Exception as e:
print("Error count is", errorCount)
traceback.print_exc()
errorCount += 1
if errorCount > 50:
exit(-1)
continue
def run_once():
baby_monitor = babytrump.TwitterBabyMonitor()
run_now(baby_monitor)