-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathYugiohTool.py
271 lines (248 loc) · 11.2 KB
/
YugiohTool.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/usr/bin/python
# coding:utf-8
"""
@author: zyatom
@contact: 70906346@qq.com
@software: PyCharm
@file: YugiohTool.py
@time: 2020/4/21 20:50
"""
import importlib
import msvcrt
import os
import sys
import time
import win32gui
import threading
import inspect
import ctypes
import configparser
import requests
from YugiohToolSteam import Steam
from YugiohToolMoniqi import Moniqi
from YugiohToolErrorSteam import ErrorSteam
from YugiohToolErrorMoniqi import ErrorMoniqi
from YugiohToolRebootSteam import RebootSteam
from YugiohToolRebootMoniqi import RebootMoniqi
from regist import regist as reg
importlib.reload(sys)
tuisong_time = None
try:
temp = ctypes.windll.LoadLibrary('opencv_videoio_ffmpeg420_64.dll')
except:
pass
def _async_raise(tid, exctype): # 关闭线程
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stop_thread(thread): # 关闭线程
_async_raise(thread.ident, SystemExit)
def tuisong(cishu, text, serviceapi): # 推送到手机
api = serviceapi
title = "脚本运行" + str(cishu) + "次" + "," + text
content = text
data = {
"text": title,
"desp": content
}
requests.post(api, data=data)
def tuisongfunction(endTime):
global tuisong_time
cf = configparser.ConfigParser()
cf.read("config.ini") # 读取配置文件
count = int(cf.get("config", "count"))
start_count = count
start_time = time.time()
serviceapi = cf.get("config", "serviceapi")
filename = "config.ini" # 监控配置文件改动
while True:
time.sleep(10)
cf.read("config.ini") # 读取配置文件
info = os.stat(filename)
count = int(cf.get("config", "count"))
scount = int(cf.get("config", "scount"))
if int(str(time.localtime().tm_min)[-1]) is 0:
# 文件没有改动超过10分钟且运行时间超过10分钟微信推送提醒
if time.time() - info.st_mtime > 590 and time.time() - start_time > 590:
if tuisong_time is None or time.time() - tuisong_time > 60: # 防止重复推送
count_per_hour = count - start_count
tuisong(count_per_hour, "脚本异常,重启游戏中...", serviceapi)
tuisong_time = time.time()
start_count = count
reboot()
# 整点发送推送
if int(str(time.localtime().tm_min)) == 00:
if time.time() - info.st_mtime < 600:
if tuisong_time is None or time.time() - tuisong_time > 60: # 防止重复推送
count_per_hour = count - start_count
start_count = count
tuisong(count_per_hour, "一切正常!", serviceapi)
tuisong_time = time.time()
if endTime is not None:
seconds = endTime - time.time()
# m, s = divmod(seconds, 60)
# h, m = divmod(m, 60)
# print("%d:%02d:%02d" % (h, m, s))
if seconds <= 60 or scount == 1:
print("试用时间已到")
print("觉得好用的话请联系我购买完整版")
print("一分钟后脚本自动关闭...")
cf.set('config', 'scount', '1')
cf.write(open("config.ini", 'w'))
time.sleep(60)
stop_thread(t_main)
sys.exit()
else:
pass
def reboot():
steam = u'Yu-Gi-Oh! DUEL LINKS' # steam
moniqi = u'雷电模拟器' # 模拟器
hwnd_steam = win32gui.FindWindow(0, steam) # 取得窗口句柄
hwnd_moniqi = win32gui.FindWindow(0, moniqi) # 取得窗口句柄
if hwnd_steam:
RebootSteam(steam).rebootsteam()
elif hwnd_moniqi:
RebootMoniqi(moniqi).rebootmoniqi()
def error():
steam = u'Yu-Gi-Oh! DUEL LINKS' # steam
moniqi = u'雷电模拟器' # 模拟器
hwnd_steam = win32gui.FindWindow(0, steam) # 取得窗口句柄
hwnd_moniqi = win32gui.FindWindow(0, moniqi) # 取得窗口句柄
if hwnd_steam:
ErrorSteam(steam).errorsteam()
elif hwnd_moniqi:
ErrorMoniqi(moniqi).errormoniqi()
def main(mode):
steam = u'Yu-Gi-Oh! DUEL LINKS' # steam
moniqi = u'雷电模拟器' # 模拟器
hwnd_steam = win32gui.FindWindow(0, steam) # 取得窗口句柄
hwnd_moniqi = win32gui.FindWindow(0, moniqi) # 取得窗口句柄
if hwnd_steam:
while True:
print("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 1、pvpKC杯自杀 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 2、pvp排名决斗自杀 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 3、pvp休闲决斗自杀 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 4、自动十级门 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 5、pvp休闲决斗战斗 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 6、pvp排名决斗战斗 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 7、最新掷骰子活动全自动 ")
print("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("◎◎◎◎◎请输入要选择的功能前面的数字并回车◎◎◎◎◎")
print("重要说明:近期KC杯官方严查,请勿长时间用模拟器挂机!!!")
input1 = str(input(""))
if input1 == '1' or input1 == '2' or input1 == '3':
demo = Steam(steam, mode)
demo.pvp_tolose_steam(input1)
sys.exit()
elif input1 == '4':
demo = Steam(steam, mode)
demo.chuansongmen_steam()
sys.exit()
elif input1 == '5' or input1 == '6':
demo = Steam(steam, mode)
demo.pvp_towin_steam(input1)
sys.exit()
elif input1 == '7':
demo = Steam(steam, mode)
demo.huodong_zhitouzi_steam()
sys.exit()
else:
print("!!!!!输入有误,请重新输入!!!!!")
time.sleep(1)
elif hwnd_moniqi:
while True:
print("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 1、pvpKC杯自杀 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 2、pvp排名决斗自杀 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 3、pvp休闲决斗自杀 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 4、自动十级门 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 5、pvp休闲决斗战斗 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 6、pvp排名决斗战斗 ")
print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("┃ 7、最新掷骰子活动全自动 ")
print("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ")
print("◎◎◎◎◎请输入要选择的功能前面的数字并回车◎◎◎◎◎")
print("重要说明:近期KC杯官方严查,请勿长时间用模拟器挂机!!!")
input1 = str(input(""))
if input1 == '1' or input1 == '2' or input1 == '3':
demo = Moniqi(moniqi, mode)
demo.pvp_tolose_moniqi(input1)
sys.exit()
elif input1 == '4':
demo = Moniqi(moniqi, mode)
demo.chuansongmen_moniqi()
sys.exit()
elif input1 == '5' or input1 == '6':
demo = Moniqi(moniqi, mode)
demo.pvp_towin_moniqi(input1)
sys.exit()
elif input1 == '7':
demo = Moniqi(moniqi, mode)
demo.huodong_zhitouzi_moniqi()
sys.exit()
else:
print("!!!!!输入有误,请重新输入!!!!!")
time.sleep(1)
else:
print("找不到游戏王决斗链接,请打开游戏后再次尝试")
time.sleep(5)
sys.exit()
if __name__ == '__main__':
reg = reg()
resule = reg.chk_reg()
if resule == 'vip':
print('您是尊贵的VIP会员,当前版本为完整版')
# time.sleep(2)
t_tuosong = threading.Thread(target=tuisongfunction, args=(None,))
t_main = threading.Thread(target=main, args=('1',))
t_error = threading.Thread(target=error, args=())
t_tuosong.setDaemon(True)
t_error.setDaemon(True)
t_tuosong.start()
t_error.start()
t_main.start()
elif resule == 'connect failed': # 连接失败,当前时间+半小时
resule =time.time() + 1800
timeArray = time.localtime(time.time() + 1800)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print('当前为试用模式,试用截止时间%s' % otherStyleTime)
time.sleep(3)
t_tuosong = threading.Thread(target=tuisongfunction, args=(resule,))
t_main = threading.Thread(target=main, args=('2',))
t_error = threading.Thread(target=error, args=())
t_tuosong.setDaemon(True)
t_error.setDaemon(True)
t_tuosong.start()
t_error.start()
t_main.start()
else:
timeArray = time.localtime(resule) # 秒数
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print('当前为试用模式,试用截止时间%s' % otherStyleTime)
time.sleep(3)
t_tuosong = threading.Thread(target=tuisongfunction, args=(resule,))
t_main = threading.Thread(target=main, args=('2',))
t_error = threading.Thread(target=error, args=())
t_tuosong.setDaemon(True)
t_error.setDaemon(True)
t_tuosong.start()
t_error.start()
t_main.start()