Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. def get_text_in_chat(self):
  2.  
  3. printscreen_numpy = self.get_screen_shot(False)
  4. printscreen_numpy2 = printscreen_numpy[340*self.TotalGameScreen.proportionality:459*self.TotalGameScreen.proportionality,
  5. 7*self.TotalGameScreen.proportionality:498*self.TotalGameScreen.proportionality]
  6. printscreen_numpy2 = cv2.cvtColor(printscreen_numpy2, cv2.COLOR_RGB2GRAY)
  7. th1 = cv2.threshold(printscreen_numpy2, 100, 255, cv2.THRESH_BINARY)[1]
  8.  
  9. screen_text = []
  10. dirs = os.listdir(GUIInfo.EXE_SYSTEM_PATH+'ChatText')
  11. for file in dirs:
  12. filename = GUIInfo.EXE_SYSTEM_PATH+'ChatText\\'+file
  13. template = cv2.imread(filename, 0)
  14. template = cv2.threshold(template, 100, 255, cv2.THRESH_BINARY)[1]
  15. res = cv2.matchTemplate(th1,template,cv2.TM_CCORR_NORMED)
  16.  
  17. threshold = 0.99
  18. loc = np.where( res >= threshold)
  19.  
  20. for pt in zip(*loc[::-1]):
  21. if file == "ClickHereToContinue.PNG":
  22. self.click_map(pt[0]+7+84,pt[1]+340+16)
  23. elif file == "colon.PNG":
  24. screen_text.append((':',pt[0], pt[1]))
  25. else:
  26. screen_text.append((file[0],pt[0], pt[1]))
  27.  
  28. try:
  29. line2 = []
  30. line3 = []
  31. line4 = []
  32. line5 = []
  33. line6 = []
  34. line7 = []
  35. line8 = []
  36.  
  37. sorted_screen_text = sorted(screen_text, key = lambda x: (int(x[2])))
  38.  
  39. for item in sorted_screen_text:
  40. if item[2] >= 15 and item[2] <25:
  41. line2.append(item)
  42. elif item[2] >= 27 and item[2] <40:
  43. line3.append(item)
  44. elif item[2] >= 42 and item[2] <55:
  45. line4.append(item)
  46. elif item[2] >= 57 and item[2] <69:
  47. line5.append(item)
  48. elif item[2] >= 71 and item[2] <83:
  49. line6.append(item)
  50. elif item[2] >= 85 and item[2] <97:
  51. line7.append(item)
  52. elif item[2] >= 99 and item[2] <111:
  53. line8.append(item)
  54.  
  55. sorted_screen_text = sorted(line2, key = lambda x: (int(x[1])))
  56. line2 = "".join([str(item[0]) for item in sorted_screen_text])
  57.  
  58. sorted_screen_text = sorted(line3, key = lambda x: (int(x[1])))
  59. line3 = "".join([str(item[0]) for item in sorted_screen_text])
  60.  
  61. sorted_screen_text = sorted(line4, key = lambda x: (int(x[1])))
  62. line4 = "".join([str(item[0]) for item in sorted_screen_text])
  63.  
  64. sorted_screen_text = sorted(line5, key = lambda x: (int(x[1])))
  65. line5 = "".join([str(item[0]) for item in sorted_screen_text])
  66.  
  67. sorted_screen_text = sorted(line6, key = lambda x: (int(x[1])))
  68. line6 = "".join([str(item[0]) for item in sorted_screen_text])
  69.  
  70. sorted_screen_text = sorted(line7, key = lambda x: (int(x[1])))
  71. line7 = "".join([str(item[0]) for item in sorted_screen_text])
  72.  
  73. sorted_screen_text = sorted(line8, key = lambda x: (int(x[1])))
  74. line8 = "".join([str(item[0]) for item in sorted_screen_text])
  75.  
  76. for line in (line2, line3, line4, line5, line6, line7, line8):
  77. for word in Player.words_of_interest:
  78. if word in line:
  79. if word is "level":
  80. skill_level = re.findall('\d+', line)
  81. for skill in Player.skill_words:
  82. if skill in line and (skill, skill_level[0]) not in Player.notified_lines:
  83. if not GUIInfo.EXE:
  84. twilioCli.messages.create(body="Congratulations your {} level is now {}"
  85. .format(skill, skill_level[0]),
  86. from_=myTwilioNumber,
  87. to=GUIInfo.myCellPhone)
  88. Player.notified_lines.append((skill, skill_level[0]))
  89. except:
  90. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement