forked from flakas/reconbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
76 lines (67 loc) · 2.18 KB
/
run.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import schedule
import time
import sqlite3
from reconbot.tasks import notification_task
from reconbot.notifiers.caching import CachingNotifier
from reconbot.notifiers.slack import SlackNotifier
from reconbot.notifiers.splitter import SplitterNotifier
from reconbot.apiqueue import ApiQueue
db_file = 'datadump/sqlite-latest.sqlite'
slack_apis = {
'example': {
'api_key': 'xxxx-xxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx',
'username': 'reconbot',
},
}
eve_apis = {
'example-group': {
'notifications': {
'whitelist': [75, 93, 94, 95, 147, 148, 149, 160, 161, 162, 163, 181, 182, 184, 185, 188, 198],
},
'characters': {
'ccp-example-1': {
'character_name': 'CCP Example',
'character_id': 11111111,
'key_id': 2222222,
'vcode': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
'ccp-example-2': {
'character_name': 'CCP Example 2',
'character_id': 33333333,
'key_id': 4444444,
'vcode': 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
},
},
}
}
api_queue = ApiQueue(list(eve_apis['example-group']['characters'].values()))
db_connection = sqlite3.connect(db_file)
db_connection.row_factory = sqlite3.Row
db = db_connection.cursor()
def notifications_job():
notification_task(
db,
eve_apis['example-group']['notifications'],
api_queue,
CachingNotifier(
SplitterNotifier([
SlackNotifier(
slack_apis['example']['api_key'],
slack_apis['example']['username'],
'#fc',
'online'
),
SlackNotifier(
slack_apis['example']['api_key'],
slack_apis['example']['username'],
'#recon',
'all'
)
]),
duration=3600
)
)
schedule.every(31/len(eve_apis['example-group']['characters'])).minutes.do(notifications_job)
while True:
schedule.run_pending()
time.sleep(1)