-
Notifications
You must be signed in to change notification settings - Fork 62
/
logbot.py
44 lines (34 loc) · 1.23 KB
/
logbot.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
import requests, config, os
DISCORD_LOGS_URL = os.environ.get('DISCORD_LOGS_URL', config.DISCORD_LOGS_URL)
DISCORD_ERR_URL = os.environ.get('DISCORD_ERR_URL', config.DISCORD_ERR_URL)
DISCORD_AVATAR_URL = os.environ.get('DISCORD_AVATAR_URL', config.DISCORD_AVATAR_URL)
DISCORD_STUDY_URL = os.environ.get('DISCORD_STUDY_URL', config.DISCORD_STUDY_URL)
DISCORD_STUDY_AVATAR_URL = os.environ.get('DISCORD_STUDY_AVATAR_URL', config.DISCORD_STUDY_AVATAR_URL)
logs_format = {
"username": "logs",
"avatar_url": DISCORD_AVATAR_URL,
"content": ""
}
study_format = {
"username": "Tradingview Alert",
"avatar_url": DISCORD_STUDY_AVATAR_URL,
"content": ""
}
def logs(message, error=False, log_to_discord=True):
print(message)
if log_to_discord:
try:
json_logs = logs_format
json_logs['content'] = message
requests.post(DISCORD_LOGS_URL, json=json_logs)
if error:
requests.post(DISCORD_ERR_URL, json=json_logs)
except:
pass
def study_alert(message, chart_url):
try:
json_logs = study_format
json_logs['content'] = ">>> " + message + " \n\n" + chart_url
requests.post(DISCORD_STUDY_URL, json=json_logs)
except:
pass