· 6 years ago · Apr 18, 2020, 01:02 AM
1import configparser
2import operator
3import os
4import sys
5import time
6import webbrowser
7from datetime import datetime, timedelta
8
9import pushbullet
10import pyperclip
11import pytesseract
12import requests
13import win32api
14import win32con
15import win32gui
16from PIL import ImageGrab, Image
17from playsound import playsound
18
19
20def Avg(lst: list):
21 if not lst:
22 return 0
23 return sum(lst) / len(lst)
24
25
26# noinspection PyShadowingNames,PyUnusedLocal
27def enum_cb(hwnd, results):
28 winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
29
30
31# noinspection PyShadowingNames
32def write(message, add_time: bool = True, push: int = 0, push_now: bool = False, output: bool = True, overwrite: str = '0'):
33 if output:
34 message = str(message)
35 if add_time:
36 message = datetime.now().strftime('%H:%M:%S') + ': ' + message
37 overwrite_log = open(appdata_path + '\\overwrite_log.txt', 'rb+')
38 lines = overwrite_log.readlines()
39 last_key = lines[0].split(b'**')[0]
40 last_line = lines[-1].split(b'**')[-1]
41 if overwrite != '0':
42 ending = console_window[0]
43 if last_key == overwrite.encode():
44 message = console_window[1] + message
45 else:
46 if last_line != b'\n':
47 message = '\n' + message
48 else:
49 ending = '\n'
50 if last_line != b'\n':
51 message = '\n' + message
52
53 overwrite_log.seek(0)
54 overwrite_log.truncate()
55 overwrite_log.write((overwrite + '**' + message + '**' + ending).encode())
56 overwrite_log.close()
57 print(message, end=ending)
58
59 if push >= 3:
60 global note
61 if message:
62 note = note + str(message) + '\n'
63 if push_now:
64 device.push_note('CSGO AUTO ACCEPT', note)
65 note = ''
66
67
68# noinspection PyShadowingNames
69def click(x: int, y: int):
70 win32api.SetCursorPos((x, y))
71 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
72 win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
73
74
75# noinspection PyShadowingNames
76def relate_list(l_org, compare_list, relate: operator = operator.le):
77 if not l_org:
78 return False
79 truth_list = []
80 for list_part in compare_list:
81 partial_truth = []
82 for i, val in enumerate(list_part):
83 partial_truth.append(relate(l_org[i], val))
84 truth_list.append(all(partial_truth))
85 l_org = l_org[len(list_part):]
86 return any(truth_list)
87
88
89# noinspection PyShadowingNames
90def color_average(image: Image, compare_list: list):
91 average = []
92 r, g, b = [], [], []
93 data = image.getdata()
94 for i in data:
95 r.append(i[0])
96 g.append(i[1])
97 b.append(i[2])
98
99 rgb = [Avg(r), Avg(g), Avg(b)] * len(compare_list)
100 for part in compare_list:
101 for i, val in enumerate(part):
102 average.append(val - rgb[i])
103 average = list(map(abs, average))
104 return average
105
106
107# noinspection PyShadowingNames
108def getScreenShot(window_id: int, area: tuple = (0, 0, 0, 0)):
109 area = list(area)
110 win32gui.ShowWindow(window_id, win32con.SW_MAXIMIZE)
111 scaled_area = [screen_width / 2560, screen_height / 1440]
112 scaled_area = 2 * scaled_area
113 for i, _ in enumerate(area[-2:], start=len(area) - 2):
114 area[i] += 1
115 for i, val in enumerate(area, start=0):
116 scaled_area[i] = scaled_area[i] * val
117 scaled_area = list(map(int, scaled_area))
118 image = ImageGrab.grab(scaled_area)
119 return image
120
121
122# noinspection PyShadowingNames
123def getAccountsFromCfg():
124 steam_ids = ''
125 for i in config.sections():
126 if i.startswith('Account'):
127 steam_id = config.get(i, 'Steam ID')
128 auth_code = config.get(i, 'Authentication Code')
129 match_token = config.get(i, 'Match Token')
130 steam_ids += steam_id + ','
131 accounts.append({'steam_id': steam_id, 'auth_code': auth_code, 'match_token': match_token})
132
133 steam_ids = steam_ids.lstrip(',').rstrip(',')
134 profiles = requests.get('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' + cfg['steam_api_key'] + '&steamids=' + steam_ids).json()['response']['players']
135 for i in profiles:
136 for n in accounts:
137 if n['steam_id'] == i['steamid']:
138 n['name'] = i['personaname']
139 break
140
141
142# noinspection PyShadowingNames
143def getOldSharecodes(num: int = -1):
144 try:
145 last_game = open(appdata_path+'last_game_' + accounts[current_account]['steam_id'] + '.txt', 'r')
146 games = last_game.readlines()
147 last_game.close()
148 except FileNotFoundError:
149 last_game = open(appdata_path+'last_game_' + accounts[current_account]['steam_id'] + '.txt', 'w')
150 last_game.write(accounts[current_account]['match_token'] + '\n')
151 games = [accounts[current_account]['match_token']]
152 last_game.close()
153 last_game = open(appdata_path+'last_game_' + accounts[current_account]['steam_id'] + '.txt', 'w')
154 games = games[-200:]
155 for i, val in enumerate(games):
156 games[i] = 'CSGO' + val.strip('\n').split('CSGO')[1]
157 last_game.write(games[i] + '\n')
158 last_game.close()
159 return games[num:]
160
161
162# noinspection PyShadowingNames
163def getNewCSGOSharecodes(game_id: str):
164 sharecodes = []
165 next_code = game_id
166 last_game = open(appdata_path+'last_game_' + accounts[current_account]['steam_id'] + '.txt', 'a')
167 while next_code != 'n/a':
168 steam_url = 'https://api.steampowered.com/ICSGOPlayers_730/GetNextMatchSharingCode/v1?key=' + cfg['steam_api_key'] + '&steamid=' + accounts[current_account]['steam_id'] + '&steamidkey=' + accounts[current_account][
169 'auth_code'] + '&knowncode=' + game_id
170 try:
171 next_code = (requests.get(steam_url).json()['result']['nextcode'])
172 except KeyError:
173 write('WRONG Match Token, Authentication Code or Steam ID ')
174 return [game_id]
175
176 if next_code:
177 if next_code != 'n/a':
178 sharecodes.append(next_code)
179 game_id = next_code
180 last_game.write(next_code + '\n')
181 if sharecodes:
182 return sharecodes
183 else:
184 return [game_id]
185
186
187def getAllQueuedGames():
188 num = -1
189 getNewCSGOSharecodes(getOldSharecodes()[0])
190 sharecode = getOldSharecodes()
191 while True:
192 response = requests.post('https://csgostats.gg/match/upload/ajax', data={'sharecode': sharecode, 'index': '1'})
193 if response.json()['status'] != 'complete':
194 num -= 1
195 try:
196 sharecode = getOldSharecodes(num)[0]
197 except IndexError:
198 return num+1
199 else:
200 return num+1
201
202
203# noinspection PyShadowingNames
204def UpdateCSGOstats(sharecodes: list, num_completed: int = 1):
205 completed_games, not_completed_games, = [], []
206 for val in sharecodes:
207 response = requests.post('https://csgostats.gg/match/upload/ajax', data={'sharecode': val, 'index': '1'})
208 if response.json()['status'] == 'complete':
209 completed_games.append(response.json())
210 else:
211 not_completed_games.append(response.json())
212
213 queued_games = [game['data']['queue_pos'] for game in not_completed_games if game['status'] != 'error']
214 global retrying_games, queue_difference, time_table
215 current_queue_difference = Avg([last_game[1] - game['data']['queue_pos'] for game in not_completed_games for last_game in retrying_games if last_game[0] == game['data']['sharecode']])
216 if current_queue_difference:
217 queue_difference.append(current_queue_difference / ((time.time() - time_table['error_check_time']) / 60))
218 queue_difference = queue_difference[-10:]
219 time_table['error_check_time'] = time.time()
220 retrying_games = []
221
222 if queued_games:
223 if queued_games[0] < cfg['max_queue_position']:
224 retrying_games = [(str(game['data']['sharecode']), int(game['data']['queue_pos'])) for game in not_completed_games if game['status'] != 'error']
225 temp_string = ''
226 for i, val in enumerate(queued_games):
227 temp_string += '#' + str(i + 1) + ': in Queue #' + str(val) + '. - '
228 temp_string += str(round(Avg(queue_difference), 1)) + ' matches/min'
229 write(temp_string, add_time=False, overwrite='4')
230
231 if len(not_completed_games) - len(queued_games) > 0:
232 write('An error occurred in %s game[s].' % (len(not_completed_games) - len(queued_games)), add_time=False)
233 retrying_games.append([(str(game['data']['sharecode']), 0) for game in not_completed_games if game['status'] == 'error'])
234
235 if completed_games:
236 for i in completed_games[num_completed * - 1:]:
237 sharecode = i['data']['sharecode']
238 game_url = i['data']['url']
239 info = ' '.join(i['data']['msg'].replace('-', '').replace('<br />', '. ').split('<')[0].rstrip(' ').split())
240 write('Sharecode: %s' % sharecode, add_time=False, push=push_urgency)
241 write('URL: %s' % game_url, add_time=False, push=push_urgency)
242 write('Status: %s.' % info, add_time=False, push=push_urgency)
243 pyperclip.copy(game_url)
244 write(None, add_time=False, push=push_urgency, push_now=True, output=False)
245
246
247# noinspection PyShadowingNames,PyUnusedLocal
248def Image_to_Text(image: Image, size: tuple, white_threshold: tuple, arg: str = ''):
249 image_data = image.getdata()
250 pixel_map, image_text = [], ''
251 for y in range(size[1]):
252 for x in range(size[0]):
253 if relate_list(image_data[y * size[0] + x], [white_threshold], relate=operator.ge):
254 pixel_map.append((0, 0, 0))
255 else:
256 pixel_map.append((255, 255, 255))
257 temp_image = Image.new('RGB', (size[0], size[1]))
258 temp_image.putdata(pixel_map)
259 try:
260 image_text = pytesseract.image_to_string(temp_image, timeout=0.3, config=arg)
261 except RuntimeError as timeout_error:
262 pass
263 if image_text:
264 image_text = ' '.join(image_text.replace(': ', ':').split())
265 global truth_table
266 if truth_table['debugging']:
267 image.save(str(cfg['debug_path']) + '\\' + datetime.now().strftime('%H-%M-%S') + '_' + image_text.replace(':', '-') + '.png', format='PNG')
268 temp_image.save(str(cfg['debug_path']) + '\\' + datetime.now().strftime('%H-%M-%S') + '_' + image_text.replace(':', '-') + '_temp.png', format='PNG')
269 return image_text
270 else:
271 return False
272
273
274def getCfgData():
275 try:
276 get_cfg = {'activate_script': int(config.get('HotKeys', 'Activate Script'), 16), 'activate_push_notification': int(config.get('HotKeys', 'Activate Push Notification'), 16),
277 'info_newest_match': int(config.get('HotKeys', 'Get Info on newest Match'), 16), 'info_multiple_matches': int(config.get('HotKeys', 'Get Info on multiple Matches'), 16),
278 'open_live_tab': int(config.get('HotKeys', 'Live Tab Key'), 16), 'switch_accounts': int(config.get('HotKeys', 'Switch accounts for csgostats.gg'), 16),
279 'end_script': int(config.get('HotKeys', 'End Script'), 16),
280 'screenshot_interval': config.getint('Screenshot', 'Interval'), 'debug_path': config.get('Screenshot', 'Debug Path'), 'steam_api_key': config.get('csgostats.gg', 'API Key'),
281 'last_x_matches': config.getint('csgostats.gg', 'Number of Requests'),
282 'completed_matches': config.getint('csgostats.gg', 'Completed Matches'), 'max_queue_position': config.getint('csgostats.gg', 'Auto-Retrying for queue position below'),
283 'auto_retry_interval': config.getint('csgostats.gg', 'Auto-Retrying-Interval'), 'pushbullet_device_name': config.get('Pushbullet', 'Device Name'), 'pushbullet_api_key': config.get('Pushbullet', 'API Key'),
284 'tesseract_path': config.get('Warmup', 'Tesseract Path'), 'warmup_test_interval': config.getint('Warmup', 'Test Interval'), 'warmup_push_interval': config.get('Warmup', 'Push Interval'),
285 'warmup_no_text_limit': config.getint('Warmup', 'No Text Limit')}
286 return get_cfg
287 # 'imgur_id': config.get('Imgur', 'Client ID'), 'imgur_secret': config.get('Imgur', 'Client Secret'), 'stop_warmup_ocr': int(config.get('HotKeys', 'Stop Warmup OCR'), 16),
288 except (configparser.NoOptionError, configparser.NoSectionError, ValueError):
289 write('ERROR IN CONFIG')
290 exit('CHECK FOR NEW CONFIG')
291
292
293# OVERWRITE SETUP
294appdata_path = os.getenv('APPDATA') + '\\CSGO AUTO ACCEPT\\'
295try:
296 os.mkdir(appdata_path)
297except FileExistsError:
298 pass
299overwrite_log = open(appdata_path+'\\overwrite_log.txt', 'wb')
300overwrite_log.write('0**\n'.encode())
301overwrite_log.close()
302console_window = ()
303if not sys.stdout.isatty():
304 console_window = ('', '\r')
305else:
306 console_window = ('\r', '')
307
308
309
310# CONFIG HANDLING
311config = configparser.ConfigParser()
312config.read('config.ini')
313cfg = getCfgData()
314device = 0
315
316# ACCOUNT HANDLING, GETTING ACCOUNT NAME
317accounts, current_account = [], 0
318getAccountsFromCfg()
319
320# INITIALIZATION FOR getScreenShot
321screen_width, screen_height = win32api.GetSystemMetrics(0), win32api.GetSystemMetrics(1)
322toplist, winlist = [], []
323hwnd = 0
324
325# BOOLEAN, TIME INITIALIZATION
326truth_table = {'test_for_live_game': False, 'test_for_success': False, 'test_for_warmup': False, 'first_ocr': True, 'testing': False, 'debugging': False, 'first_push': True}
327time_table = {'screenshot_time': time.time(), 'error_check_time': time.time(), 'warmup_test_timer': time.time(), 'time_searching': time.time()}
328
329# csgostats.gg VAR
330retrying_games, queue_difference = [], []
331
332# WARMUP DETECTION SETUP
333pytesseract.pytesseract.tesseract_cmd = cfg['tesseract_path']
334push_times, no_text_found, push_counter = [], 0, 0
335for i in cfg['warmup_push_interval'].split(','):
336 push_times.append(int(i))
337push_times.sort(reverse=True)
338join_warmup_time = push_times[0] + 1
339
340# PUSHBULLET VAR
341note = ''
342push_urgency = 0
343
344write('READY')
345write('Current account is: %s\n' % accounts[current_account]['name'], add_time=False)
346
347while True:
348 if win32api.GetAsyncKeyState(cfg['activate_script']) & 1: # F9 (ACTIVATE / DEACTIVATE SCRIPT)
349 truth_table['test_for_live_game'] = not truth_table['test_for_live_game']
350 write('TESTING: %s' % truth_table['test_for_live_game'], overwrite='1')
351 if truth_table['test_for_live_game']:
352 playsound('sounds/activated_2.mp3')
353 time_table['time_searching'] = time.time()
354 else:
355 playsound('sounds/deactivated.mp3')
356
357 if win32api.GetAsyncKeyState(cfg['activate_push_notification']) & 1: # F8 (ACTIVATE / DEACTIVATE PUSH NOTIFICATION)
358 if not device:
359 try:
360 device = pushbullet.PushBullet(cfg['pushbullet_api_key']).get_device(cfg['pushbullet_device_name'])
361 except (pushbullet.errors.PushbulletError, pushbullet.errors.InvalidKeyError):
362 write('Pushbullet is wrongly configured.\nWrong API Key or DeviceName in config.ini')
363 if device:
364 push_urgency += 1
365 if push_urgency > 3:
366 push_urgency = 0
367 push_info = ['not active', 'only if accepted', 'all game status related information', 'all information (game status/csgostats.gg information)']
368 write('Pushing: %s' % push_info[push_urgency], overwrite='2')
369
370 if win32api.GetAsyncKeyState(cfg['info_newest_match']) & 1: # F7 Key (UPLOAD NEWEST MATCH)
371 write('Uploading / Getting status on newest match')
372 queue_difference = []
373 sharecodes = [i[0] for i in retrying_games] + getOldSharecodes(getAllQueuedGames())
374 sharecodes = sorted(set(sharecodes), key=lambda x: sharecodes.index(x))
375 UpdateCSGOstats(sharecodes, num_completed=len(sharecodes))
376
377 if win32api.GetAsyncKeyState(cfg['info_multiple_matches']) & 1: # F6 Key (GET INFO ON LAST X MATCHES)
378 write('Getting Info from last %s matches' % cfg['last_x_matches'])
379 queue_difference = []
380 getNewCSGOSharecodes(getOldSharecodes()[0])
381 UpdateCSGOstats(getOldSharecodes(num=cfg['last_x_matches'] * -1), num_completed=cfg['completed_matches'])
382
383 if win32api.GetAsyncKeyState(cfg['open_live_tab']) & 1: # F13 Key (OPEN WEB BROWSER ON LIVE GAME TAB)
384 win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
385 webbrowser.open_new_tab('https://csgostats.gg/player/' + accounts[current_account]['steam_id'] + '#/live')
386 write('new tab opened', add_time=False)
387 time.sleep(0.5)
388 win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
389
390 if win32api.GetAsyncKeyState(cfg['switch_accounts']) & 1: # F15 (SWITCH ACCOUNTS)
391 current_account += 1
392 if current_account > len(accounts) - 1:
393 current_account = 0
394 write('current account is: %s' % accounts[current_account]['name'], add_time=False, overwrite='3')
395
396 if win32api.GetAsyncKeyState(cfg['end_script']) & 1: # POS1 (END SCRIPT)
397 write('Exiting Script')
398 break
399
400 if retrying_games:
401 if time.time() - time_table['error_check_time'] > cfg['auto_retry_interval']:
402 temp_list = [i[0] for i in retrying_games]
403 UpdateCSGOstats(temp_list, num_completed=len(temp_list))
404
405 winlist = []
406 win32gui.EnumWindows(enum_cb, toplist)
407 csgo = [(hwnd, title) for hwnd, title in winlist if 'counter-strike: global offensive' in title.lower()]
408
409 # ONLY CONTINUING IF CSGO IS RUNNING
410 if not csgo:
411 continue
412 hwnd = csgo[0][0]
413
414 # TESTING HERE
415 if win32api.GetAsyncKeyState(0x6F) & 1: # UNBOUND, TEST CODE
416 # truth_table['testing'] = not truth_table['testing']
417 truth_table['debugging'] = not truth_table['debugging']
418 # truth_table['test_for_warmup'] = not truth_table['test_for_warmup']
419 # time_table['warmup_test_timer'] = time.time() + 2
420 write('DEBUGGING: %s\n' % truth_table['debugging'])
421
422 if truth_table['testing']:
423 # time_table['screenshot_time'] = time.time()
424 pass
425 # print('Took: %s ' % str(timedelta(milliseconds=int(time.time(*1000 - time_table['screenshot_time']*1000))))
426 # TESTING ENDS HERE
427
428 if truth_table['test_for_live_game']:
429 if time.time() - time_table['screenshot_time'] < cfg['screenshot_interval']:
430 continue
431 time_table['screenshot_time'] = time.time()
432 img = getScreenShot(hwnd, (1265, 760, 1295, 785))
433 if not img:
434 continue
435 accept_avg = color_average(img, [(76, 176, 80), (89, 203, 94)])
436 if relate_list(accept_avg, [(2, 2, 2), (2, 2, 2)]):
437 write('Trying to Accept', push=push_urgency + 1)
438
439 truth_table['test_for_success'] = True
440 truth_table['test_for_live_game'] = False
441 accept_avg = []
442
443 for _ in range(5):
444 click(int(screen_width / 2), int(screen_height / 1.78))
445 pass
446
447 write('Trying to catch a loading map')
448 playsound('sounds/accept_found.mp3')
449 time_table['screenshot_time'] = time.time()
450
451 if truth_table['test_for_success']:
452 if time.time() - time_table['screenshot_time'] < 40:
453 img = getScreenShot(hwnd, (2435, 65, 2555, 100))
454 not_searching_avg = color_average(img, [(6, 10, 10)])
455 searching_avg = color_average(img, [(6, 163, 97), (4, 63, 35)])
456
457 not_searching = relate_list(not_searching_avg, [(2, 5, 5)])
458 searching = relate_list(searching_avg, [(2.7, 55, 35), (1, 50, 35)])
459
460 img = getScreenShot(hwnd, (467, 1409, 1300, 1417))
461 success_avg = color_average(img, [(21, 123, 169)])
462 success = relate_list(success_avg, [(1, 8, 7)])
463
464 if success:
465 write('Took %s since pressing accept.' % str(timedelta(seconds=int(time.time() - time_table['screenshot_time']))), add_time=False, push=push_urgency + 1)
466 write('Took %s since trying to find a game.' % str(timedelta(seconds=int(time.time() - time_table['time_searching']))), add_time=False, push=push_urgency + 1)
467 write('Game should have started', push=push_urgency + 2, push_now=True)
468 truth_table['test_for_success'] = False
469 truth_table['test_for_warmup'] = True
470 playsound('sounds/done_testing.mp3')
471 time_table['warmup_test_timer'] = time.time() + 5
472
473 if any([searching, not_searching]):
474 write('Took: %s ' % str(timedelta(seconds=int(time.time() - time_table['screenshot_time']))), add_time=False, push=push_urgency + 1)
475 write('Game doesnt seem to have started. Continuing to search for accept Button!', push=push_urgency + 1, push_now=True)
476 playsound('sounds/back_to_testing.mp3')
477 truth_table['test_for_success'] = False
478 truth_table['test_for_live_game'] = True
479
480 else:
481 write('40 Seconds after accept, did not find loading map nor searching queue')
482 truth_table['test_for_success'] = False
483 print(success_avg)
484 print(searching_avg)
485 print(not_searching_avg)
486 playsound('sounds/fail.mp3')
487 img.save(os.path.expanduser('~') + '\\Unknown Error.png')
488
489 if truth_table['test_for_warmup']:
490 for i in range(112, 113): # 136
491 win32api.GetAsyncKeyState(i) & 1
492 while True:
493 keys = []
494 for i in range(112, 113):
495 keys.append(win32api.GetAsyncKeyState(i) & 1)
496 if any(keys):
497 write('Break from warmup-loop')
498 truth_table['test_for_warmup'] = False
499 truth_table['first_ocr'] = True
500 truth_table['first_push'] = True
501 break
502
503 if time.time() - time_table['warmup_test_timer'] >= cfg['warmup_test_interval']:
504 img = getScreenShot(hwnd, (1036, 425, 1525, 456)) # 'WAITING FOR PLAYERS X:XX'
505 img_text = Image_to_Text(img, img.size, (225, 225, 225), arg='--psm 6')
506 time_table['warmup_test_timer'] = time.time()
507 if img_text:
508 time_left = img_text.split()[-1].split(':')
509 # write(img_text, add_time=False)
510 try:
511 time_left = int(time_left[0]) * 60 + int(time_left[1])
512 if truth_table['first_ocr']:
513 join_warmup_time = time_left
514 time_table['screenshot_time'] = time.time()
515 truth_table['first_ocr'] = False
516
517 except ValueError:
518 time_left = push_times[0] + 1
519
520 time_left_data = timedelta(seconds=int(time.time() - time_table['screenshot_time'])), time.strftime('%H:%M:%S', time.gmtime(abs((join_warmup_time - time_left) - (time.time() - time_table['screenshot_time'])))), img_text
521 write('Time since start: %s - Time Difference: %s - Time left: %s' % (time_left_data[0], time_left_data[1], time_left_data[2]), add_time=False, overwrite='1')
522 if no_text_found > 0:
523 no_text_found -= 1
524
525 if time_left <= push_times[push_counter]:
526 push_counter += 1
527 write('Time since start: %s\nTime Difference: %s\nTime left: %s' % (time_left_data[0], time_left_data[1], time_left_data[2]), push=push_urgency + 1, output=False, push_now=True)
528
529 if truth_table['first_push']:
530 if abs((join_warmup_time - time_left) - (time.time() - time_table['screenshot_time'])) >= 5:
531 truth_table['first_push'] = False
532 write('Match should start in ' + str(time_left) + 'seconds, All players have connected', push=push_urgency + 2, push_now=True)
533
534 else:
535 no_text_found += 1
536
537 if push_counter >= len(push_times):
538 push_counter = 0
539 no_text_found = 0
540 truth_table['test_for_warmup'] = False
541 truth_table['first_ocr'] = True
542 truth_table['first_push'] = True
543 write('Warmup should be over in less then %s seconds!' % push_times[-1], push=push_urgency + 2, push_now=True)
544 break
545
546 if no_text_found >= cfg['warmup_no_text_limit']:
547 push_counter = 0
548 no_text_found = 0
549 truth_table['test_for_warmup'] = False
550 truth_table['first_ocr'] = True
551 truth_table['first_push'] = True
552 write('Did not find any warmup text.', push=push_urgency + 2, push_now=True)
553 break
554
555exit('ENDED BY USER')