Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_text_in_chat(self):
- printscreen_numpy = self.get_screen_shot(False)
- printscreen_numpy2 = printscreen_numpy[340*self.TotalGameScreen.proportionality:459*self.TotalGameScreen.proportionality,
- 7*self.TotalGameScreen.proportionality:498*self.TotalGameScreen.proportionality]
- printscreen_numpy2 = cv2.cvtColor(printscreen_numpy2, cv2.COLOR_RGB2GRAY)
- th1 = cv2.threshold(printscreen_numpy2, 100, 255, cv2.THRESH_BINARY)[1]
- screen_text = []
- dirs = os.listdir(GUIInfo.EXE_SYSTEM_PATH+'ChatText')
- for file in dirs:
- filename = GUIInfo.EXE_SYSTEM_PATH+'ChatText\\'+file
- template = cv2.imread(filename, 0)
- template = cv2.threshold(template, 100, 255, cv2.THRESH_BINARY)[1]
- res = cv2.matchTemplate(th1,template,cv2.TM_CCORR_NORMED)
- threshold = 0.99
- loc = np.where( res >= threshold)
- for pt in zip(*loc[::-1]):
- if file == "ClickHereToContinue.PNG":
- self.click_map(pt[0]+7+84,pt[1]+340+16)
- elif file == "colon.PNG":
- screen_text.append((':',pt[0], pt[1]))
- else:
- screen_text.append((file[0],pt[0], pt[1]))
- try:
- line2 = []
- line3 = []
- line4 = []
- line5 = []
- line6 = []
- line7 = []
- line8 = []
- sorted_screen_text = sorted(screen_text, key = lambda x: (int(x[2])))
- for item in sorted_screen_text:
- if item[2] >= 15 and item[2] <25:
- line2.append(item)
- elif item[2] >= 27 and item[2] <40:
- line3.append(item)
- elif item[2] >= 42 and item[2] <55:
- line4.append(item)
- elif item[2] >= 57 and item[2] <69:
- line5.append(item)
- elif item[2] >= 71 and item[2] <83:
- line6.append(item)
- elif item[2] >= 85 and item[2] <97:
- line7.append(item)
- elif item[2] >= 99 and item[2] <111:
- line8.append(item)
- sorted_screen_text = sorted(line2, key = lambda x: (int(x[1])))
- line2 = "".join([str(item[0]) for item in sorted_screen_text])
- sorted_screen_text = sorted(line3, key = lambda x: (int(x[1])))
- line3 = "".join([str(item[0]) for item in sorted_screen_text])
- sorted_screen_text = sorted(line4, key = lambda x: (int(x[1])))
- line4 = "".join([str(item[0]) for item in sorted_screen_text])
- sorted_screen_text = sorted(line5, key = lambda x: (int(x[1])))
- line5 = "".join([str(item[0]) for item in sorted_screen_text])
- sorted_screen_text = sorted(line6, key = lambda x: (int(x[1])))
- line6 = "".join([str(item[0]) for item in sorted_screen_text])
- sorted_screen_text = sorted(line7, key = lambda x: (int(x[1])))
- line7 = "".join([str(item[0]) for item in sorted_screen_text])
- sorted_screen_text = sorted(line8, key = lambda x: (int(x[1])))
- line8 = "".join([str(item[0]) for item in sorted_screen_text])
- for line in (line2, line3, line4, line5, line6, line7, line8):
- for word in Player.words_of_interest:
- if word in line:
- if word is "level":
- skill_level = re.findall('\d+', line)
- for skill in Player.skill_words:
- if skill in line and (skill, skill_level[0]) not in Player.notified_lines:
- if not GUIInfo.EXE:
- twilioCli.messages.create(body="Congratulations your {} level is now {}"
- .format(skill, skill_level[0]),
- from_=myTwilioNumber,
- to=GUIInfo.myCellPhone)
- Player.notified_lines.append((skill, skill_level[0]))
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement