From f976d2c308cbd0777640805ad3795419c48b5d0b Mon Sep 17 00:00:00 2001 From: Queue Date: Tue, 14 Nov 2017 20:06:39 +0100 Subject: [PATCH 1/4] fix: mafbot.py print(e) old python2 syntax doesn't work anymore so I had to change 'print e' to print(e) --- mafbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mafbot.py b/mafbot.py index 9d20743..4826348 100755 --- a/mafbot.py +++ b/mafbot.py @@ -25,5 +25,5 @@ do_crime(1) time.sleep(60) except Exception as e: - print e + print(e) From 8e9f76cf54ed53958ed44109a21558dcde5d2971 Mon Sep 17 00:00:00 2001 From: Queue Date: Tue, 14 Nov 2017 20:12:32 +0100 Subject: [PATCH 2/4] fix: utils/captcha/dimensions not in integers no clue why it returned some float that the next function, img.crop() can't use? IDK what I'm doing --- .gitignore | 1 + mafbot/utils.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 96a0960..4f7f85c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.pyc *.pio .env/ +geckodriver.log # Misc conf.py diff --git a/mafbot/utils.py b/mafbot/utils.py index 5679bfd..6a11095 100644 --- a/mafbot/utils.py +++ b/mafbot/utils.py @@ -49,8 +49,7 @@ def inner(*args, **kwargs): lowest_rms = () for button in submit_buttons: - dimensions = (button.location['x'], button.location['y'], button.location['x'] + button.size['width'], button.location['y'] + button.size['height']) - + dimensions = (int(button.location['x']), int(button.location['y']), int(button.location['x']) + int(button.size['width']), int(button.location['y']) + int(button.size['height'])) button_img = screen_img.crop(dimensions) button_img.save(button_path) From 8a0f27236ef80914e4b0c0394fcf0dae60da0bf0 Mon Sep 17 00:00:00 2001 From: Queue Date: Tue, 14 Nov 2017 20:15:01 +0100 Subject: [PATCH 3/4] fixed: reduce not defined in python3, reduce was removed from the core thingy so I had to explicitly import the functools module --- mafbot/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mafbot/utils.py b/mafbot/utils.py index 6a11095..3437bfd 100644 --- a/mafbot/utils.py +++ b/mafbot/utils.py @@ -3,7 +3,7 @@ from PIL import Image import math import operator - +import functools from mafbot import driver from mafbot.authentication import login @@ -53,7 +53,7 @@ def inner(*args, **kwargs): button_img = screen_img.crop(dimensions) button_img.save(button_path) - rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, ref_button.histogram(), button_img.histogram()))/len(ref_button.histogram())) + rms = math.sqrt(functools.reduce(operator.add,map(lambda a,b: (a-b)**2, ref_button.histogram(), button_img.histogram()))/len(ref_button.histogram())) if len(lowest_rms) == 0 or rms < lowest_rms[1]: lowest_rms = (button, rms) From 05c5e78d24b3ec4a66f54d1cb4c618727b300242 Mon Sep 17 00:00:00 2001 From: Queue Date: Tue, 14 Nov 2017 20:22:58 +0100 Subject: [PATCH 4/4] utils captcha(f) doesn't work --- mafbot/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mafbot/utils.py b/mafbot/utils.py index 3437bfd..d534526 100644 --- a/mafbot/utils.py +++ b/mafbot/utils.py @@ -53,6 +53,8 @@ def inner(*args, **kwargs): button_img = screen_img.crop(dimensions) button_img.save(button_path) + # I don't know what this does, exactly, + # but in the new version ( and tested in py2.7, it doesn't work anymore.) rms = math.sqrt(functools.reduce(operator.add,map(lambda a,b: (a-b)**2, ref_button.histogram(), button_img.histogram()))/len(ref_button.histogram())) if len(lowest_rms) == 0 or rms < lowest_rms[1]: