-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRsiProcessCheck_alertBot.py
58 lines (47 loc) · 1.56 KB
/
RsiProcessCheck_alertBot.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
import sys
import requests
import datetime
import os
def post_message(token, channel, text):
response = requests.post(
"https://slack.com/api/chat.postMessage",
headers={"Authorization": "Bearer " + token},
data={"channel": channel, "text": text},
)
print(response)
def nowtime():
now = datetime.datetime.today().strftime("%y-%m-%d %H:%M:%S") # 현재 DateTime
return now
myToken = os.environ["Slack_Token"] # Access Token
myChannel = "비트코인-자동매매-1" # 채널 이름 OR 채널 ID
ProcessStatus = str(sys.argv[1]) # 프로세스 상태 코드 (매개 변수)
try:
if ProcessStatus == "ok":
post_message(myToken, myChannel, " ")
post_message(
myToken,
myChannel,
"$$📈🟢 Trading Process Alive$$\nServer Time : " + str(nowtime()),
)
elif ProcessStatus == "dead":
post_message(myToken, myChannel, " ")
post_message(
myToken,
myChannel,
"!!🏴☠️ Trading Process Dead!!\nServer Time : " + str(nowtime()),
)
elif ProcessStatus == "restart":
post_message(myToken, myChannel, " ")
post_message(
myToken, myChannel, "🔧 Restarting Now ...\nServer Time : " + str(nowtime())
)
else:
post_message(myToken, myChannel, " ")
post_message(
myToken,
myChannel,
"❗🔴 Sorry, Restarting Fail ... Please Check Process\nServer Time : "
+ str(nowtime()),
)
except Exception as e:
print(e)