forked from wdvipa/GlaDosCheckin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglados.py
More file actions
256 lines (237 loc) · 8.22 KB
/
glados.py
File metadata and controls
256 lines (237 loc) · 8.22 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# -*- coding: utf-8 -*-
"""
//更新时间:2023/10/26
//作者:wdvipa
//支持青龙和actions定时执行
//使用方法:创建变量 名字:glados 内容的写法:Cookie 多个账号用回车键隔开
//例如:
koa:sess=xxx;koa:sess.sig=xxx;
koa:sess=xxx;koa:sess.sig=xxx;
//更新内容:支持青龙执行,因pushplus需要实名,所以增加息知推送
//如需推送将需要的推送写入变量glados_fs即可多个用&隔开
如:变量内输入push需再添加glados_push变量 内容是push的token即可
"""
import requests
import os
import time
import re
import json
requests.urllib3.disable_warnings()
# ------------------设置-------------------
UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.26'
# 初始化环境变量开头
cs = 0
ZData = "5"
ttoken = ""
tuserid = ""
push_token = ""
xizhi_token = ""
SKey = ""
QKey = ""
ktkey = ""
msgs = ""
datas = ""
message = ""
# 检测推送
if cs == 1:
if "cs_glados" in os.environ:
datas = os.environ.get("cs_glados")
else:
print('您没有输入任何信息')
exit
elif cs == 2:
datas = ""
else:
if "glados_fs" in os.environ:
fs = os.environ.get('glados_fs')
fss = fs.split("&")
if "tel" in fss:
if "glados_telkey" in os.environ:
telekey = os.environ.get("glados_telkey")
telekeys = telekey.split('\n')
ttoken = telekeys[0]
tuserid = telekeys[1]
if "qm" in fss:
if "glados_qkey" in os.environ:
QKey = os.environ.get("glados_qkey")
if "stb" in fss:
if "glados_skey" in os.environ:
SKey = os.environ.get("glados_skey")
if "push" in fss:
if "glados_push" in os.environ:
push_token = os.environ.get("glados_push")
if "xizhi" in fss:
if "glados_xizhi" in os.environ:
push_token = os.environ.get("glados_xizhi")
if "kt" in fss:
if "glados_ktkey" in os.environ:
ktkey = os.environ.get("glados_ktkey")
if "glados" in os.environ:
datas = os.environ.get("glados")
else:
print('您没有输入任何信息')
exit
groups = datas.split('\n')
# 初始化环境变量结尾
class gladosanelQd(object):
def __init__(self, cookie):
# Authorization
self.ck = ck
self.checkReturn = ""
self.signReturn = ""
def buildHeaders(self, cookie): # 更改cookie
session.headers["Cookie"] = cookie
def status(self): # 验证
url = "https://glados.rocks/api/user/status"
payload = ""
response = session.request("GET", url, data=payload)
#print(response.text)
return response
def sign(self): # 签到
url = "https://glados.rocks/api/user/checkin"
payload = "{\"token\":\"glados.one\"}"
response = session.request("POST", url, data=payload)
#print(response.text)
return response
def main(self):
global msgs
# 更新cookie
self.buildHeaders(self.ck)
# 每日签到
self.signReturn = self.sign()
timeday = ""
email = ""
sign_msg = ""
state = self.status()
timeday = state.json()['data']['leftDays'].split('.')[0]
email = state.json()['data']['email']
if 'message' in self.signReturn.text:
sign_msg = self.signReturn.json()["message"]
if sign_msg == "Checkin Repeats! Please Try Tomorrow":
sign_msg = "重复签到,请明日再试"
else:
sign_msg = "签到失败"
message = '''⏰当前时间:{}
GlaDos签到
####################
🧐账号:{}
💻签到结果:{}
剩余天数:{}
####################
祝您过上美好的一天!'''.format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())), email, sign_msg,
timeday)
print(message)
msgs = msgs + '\n' + message
return message
class push:
# Qmsg私聊推送
def Qmsg_send(msg):
if QKey == '':
return
qmsg_url = 'https://qmsg.zendee.cn/send/' + str(QKey)
data = {
'msg': msg,
}
requests.post(qmsg_url, data=data)
# Server酱推送
def server_send(self, msg):
if SKey == '':
return
server_url = "https://sctapi.ftqq.com/" + str(SKey) + ".send"
data = {
'text': self.name + "glados签到通知",
'desp': msg
}
requests.post(server_url, data=data)
# 酷推QQ推送
def kt_send(msg):
if ktkey == '':
return
kt_url = 'https://push.xuthus.cc/send/' + str(ktkey)
data = ('glados签到完成,点击查看详细信息~\n' + str(msg)).encode("utf-8")
requests.post(kt_url, data=data)
# Telegram私聊推送
def tele_send(self, msg: str, tele_api_url, tele_bot_token, tele_user_id):
if tele_bot_token == '':
return
tele_url = f"{tele_api_url}/bot{tele_bot_token}/sendMessage"
data = {
'chat_id': tele_user_id,
'parse_mode': "Markdown",
'text': msg
}
requests.post(tele_url, data=data)
# xiZhi推送
def xiZhi_send(msg):
if xizhi_token == '':
return
title = 'Glados每日通知'
content = msg
url = f'https://xizhi.qqoq.net/{xizhi_token}.send'
data = {
"title": title,
"content": content
}
body = json.dumps(data).encode(encoding='utf-8')
headers = {'Content-Type': 'application/json'}
res = requests.post(url, data=body, headers=headers)
if res.status_code == 200:
print("息知推送成功")
# Pushplus推送
def pushplus_send(msg):
if push_token == '':
return
token = push_token
title = 'glados签到通知'
content = msg
url = 'http://www.pushplus.plus/send'
data = {
"token": token,
"title": title,
"content": content
}
body = json.dumps(data).encode(encoding='utf-8')
headers = {'Content-Type': 'application/json'}
re = requests.post(url, data=body, headers=headers)
print(re.status_code)
if __name__ == '__main__': # 直接运行和青龙入口
i = 0
n = 0
#print("已设置不显示账号密码等信息")
while i < len(groups):
n = n + 1
group = groups[i]
ck = group
msgs = msgs + "第" + str(n) + "用户的签到结果"
print("第" + str(n) + "个用户开始签到")
session = requests.session()
# --------------------以下非特殊情况不要动---------------------
session.headers = {
'Accept': "application/json, text/plain, */*",
#'Authorization': "",可选
'Sec-Fetch-Site': "same-origin",
'sec-ch-ua': "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Microsoft Edge\";v=\"114\"",
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.43",
'sec-ch-ua-mobile': "?0",
'Content-Type': "application/json;charset=UTF-8",
'Sec-Fetch-Dest': "empty",
'Host': "glados.rocks",
'Origin': "https://glados.rocks",
'Sec-Fetch-Mode': "cors",
'sec-ch-ua-platform': "\"Windows\"",
'Accept-Encoding': "gzip, deflate, br",
'Accept-Language': "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
'Connection': "keep-alive"
}
# --------------------以上非特殊情况不要动---------------------
run = gladosanelQd(ck)
run.main()
time.sleep(5)
i += 1
else:
# gladosanelQd.server_send( msgs )
push.kt_send(msgs)
# gladosanelQd.Qmsg_send(gladosanelQd.name+"\n"+gladosanelQd.email+"\n"+ msgs)
# gladosanelQd.tele_send(gladosanelQd.name+"\n"+gladosanelQd.email+"\n"+ msgs)
push.pushplus_send(msgs)
push.xiZhi_send(msgs)