-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdriver.py
57 lines (49 loc) · 1.19 KB
/
driver.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import json
import datetime
import traceback
import queue
import logging
from bot import cowBot
from server import webHook
from logger import getLogger
logger = getLogger(__name__)
def getConf(storage):
if os.path.exists(storage):
return json.loads(open(storage, 'r').read())
conf = {}
conf['bot'] = {'token': 'BOTTOKEN', 'url': 'https://example.com:8443/'}
conf['web'] = {'cert': 'CERTFILE', 'pubkey': 'PUBKEYFILE'}
conf['news'] = {
'host': 'HOST',
'auth': 'HOST',
'port': 443,
'user': 'UNAME',
'pass': 'PASS',
'last': 'lpost_file',
'timezone': 3 # Timezone difference to UTC-Z in the form of: x or -x
}
conf['db'] = {
'host': 'HOST',
'user': 'USER',
'pass': 'PASS',
'name': 'DBNAME'
}
with open(storage, 'w') as f:
json.dump(conf, f)
return conf
def main():
try:
conf = getConf('conf.ini')
q = queue.Queue()
bot = cowBot(conf, q)
wh = webHook(conf, q)
bot.start()
wh.start()
bot.join()
except Exception as e:
logger.critical('{} {}', e, datetime.datetime.now())
traceback.print_exc()
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
main()