-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.py
71 lines (48 loc) · 1.41 KB
/
helper.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
import config
import logging
log = logging.getLogger(__name__)
def any_dry_run():
dry_run_count = 0
if config.TWITTER_ACTIVE and config.TWITTER_DRY_RUN:
dry_run_count += 1
if config.MATRIX_ACTIVE and config.MATRIX_DRY_RUN:
dry_run_count += 1
if config.MASTODON_ACTIVE and config.MASTODON_DRY_RUN:
dry_run_count += 1
if config.DISCORD_ACTIVE and config.DISCORD_DRY_RUN:
dry_run_count += 1
return dry_run_count > 0
def data_valid(data_list):
for config_data in data_list:
if config_data == '':
return False
return True
def can_twitter():
required_config_data = [
config.TWITTER_TOKEN,
config.TWITTER_TOKEN_SECRET,
config.TWITTER_API_KEY,
config.TWITTER_API_SECRET,
]
return data_valid(required_config_data)
def can_mastodon():
required_config_data = [
config.MASTODON_API_BASE_URL,
config.MASTODON_ACCESS_TOKEN
]
return data_valid(required_config_data)
def can_matrix():
required_config_data = [
config.MATRIX_SERVER,
config.MATRIX_USER_NAME,
config.MATRIX_PASSWORD,
config.MATRIX_ROOM_ID
]
return data_valid(required_config_data)
def can_discord():
required_config_data = [
config.DISCORD_APP_ID,
config.DISCORD_TOKEN,
config.DISCORD_CHANNEL_ID,
]
return data_valid(required_config_data)