-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwarnbot.py
executable file
·30 lines (25 loc) · 1018 Bytes
/
warnbot.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
#!/usr/bin/env python3
# - coding: utf-8 -
import tootbotlib
import config
import importlib
import locale
import traceback
from datetime import datetime
fetch_module = importlib.import_module(config.data_fetcher)
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
tootbotlib.setup(config.user_key_file, config.owner)
with open(config.log_file, "a") as log:
log.write("="*5 + config.app_name + "="*5 + datetime.isoformat(datetime.now())+ "\n")
try:
toottext, nextmatchtime = fetch_module.fetch_data()
with open(config.log_file, "a") as log:
log.write("Got parsed data at " + datetime.isoformat(datetime.now())+ "\n")
tootbotlib.toot_once(toottext, nextmatchtime, statefilename=config.state_file, hours_before=config.hours_before)
with open(config.log_file, "a") as log:
log.write("Done at " + datetime.isoformat(datetime.now())+ "\n")
except Exception as e:
tootbotlib.toot_owner(e)
print(e)
with open(config.log_file, "a") as log:
traceback.print_exc(file=log)