forked from isecret/leigod-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleigod-helper.sh
51 lines (44 loc) · 1.49 KB
/
leigod-helper.sh
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
#!/bin/sh
# https://github.com/isecret/leigod-helper/blob/main/leigod-helper.sh
USERNAME="${USERNAME:-phone}"
PASSWORD="${PASSWORD:-password}"
if ! command -v "jq" > /dev/null; then
echo "缺失 jq 依赖";
exit;
fi
if command -v md5sum > /dev/null; then
password_hash=$(echo -n "$PASSWORD" | md5sum | awk '{print $1}')
elif command -v md5 > /dev/null; then
password_hash=$(echo -n "$PASSWORD" | md5)
else
echo "缺失 md5 或 md5sum 依赖,请手动安装"
exit 1
fi
login=$(curl -Lks -X POST https://webapi.leigod.com/api/auth/login \
-H 'content-type: application/json' \
-d "{
\"account_token\": null,
\"country_code\": 86,
\"lang\": \"zh_CN\",
\"password\": \"$password_hash\",
\"region_code\": 1,
\"src_channel\": \"guanwang\",
\"user_type\": \"0\",
\"username\": \"$USERNAME\"
}")
login_code=$(echo $login | jq -r ".code" 2>&1)
login_msg=$(echo $login | jq -r ".msg" 2>&1)
if [ "$login_code" -eq 0 ]; then
account_token=$(echo $login | jq -r ".data.login_info.account_token" 2>&1)
pause=$(curl -Lks -X POST https://webapi.leigod.com/api/user/pause \
-H 'content-type: application/json' \
-d "{
\"account_token\": \"$account_token\",
\"lang\": \"zh_CN\"
}")
pause_code=$(echo $pause | jq -r ".code" 2>&1)
pause_msg=$(echo $pause | jq -r ".msg" 2>&1)
echo "暂停结果: $pause_msg"
else
echo "登录失败...原因: $login_msg"
fi