change feature name as \'away from keybord\'

master
CHUN YU YAO 2023-01-13 08:43:16 +08:00
parent 8b110b0e74
commit 680d4ee1ed
2 changed files with 18 additions and 12 deletions

View File

@ -48,7 +48,7 @@ except Exception as exc:
import ssl import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = u"MaxBot (2023.01.12)3版" CONST_APP_VERSION = u"MaxBot (2023.01.13) ver.2"
CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com" CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com"
@ -1690,7 +1690,7 @@ def tixcraft_reload_captcha(driver):
return ret return ret
#PS: credit to LinShihJhang's share #PS: credit to LinShihJhang's share
def tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, ocr_captcha_force_submit, previous_answer): def tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, away_from_keyboard_enable, previous_answer):
print("start to ddddocr") print("start to ddddocr")
from NonBrowser import NonBrowser from NonBrowser import NonBrowser
@ -1715,7 +1715,7 @@ def tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, ocr_captcha_force_su
if len(orc_answer)==4: if len(orc_answer)==4:
who_care_var, is_form_sumbited = tixcraft_keyin_captcha_code(driver, answer = orc_answer, auto_submit = ocr_captcha_with_submit) who_care_var, is_form_sumbited = tixcraft_keyin_captcha_code(driver, answer = orc_answer, auto_submit = ocr_captcha_with_submit)
else: else:
if not ocr_captcha_force_submit: if not away_from_keyboard_enable:
tixcraft_keyin_captcha_code(driver) tixcraft_keyin_captcha_code(driver)
tixcraft_toast(driver, "※ Ocr fail...") tixcraft_toast(driver, "※ Ocr fail...")
else: else:
@ -1724,7 +1724,6 @@ def tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, ocr_captcha_force_su
previous_answer = orc_answer previous_answer = orc_answer
print("click captcha again") print("click captcha again")
tixcraft_reload_captcha(driver) tixcraft_reload_captcha(driver)
time.sleep(0.3)
else: else:
print("orc_answer is None") print("orc_answer is None")
print("previous_answer:", previous_answer) print("previous_answer:", previous_answer)
@ -1732,6 +1731,7 @@ def tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, ocr_captcha_force_su
tixcraft_keyin_captcha_code(driver) tixcraft_keyin_captcha_code(driver)
else: else:
# page is not ready, retry again. # page is not ready, retry again.
# PS: usually occur in async script get captcha image.
is_need_redo_ocr = True is_need_redo_ocr = True
return is_need_redo_ocr, previous_answer, is_form_sumbited return is_need_redo_ocr, previous_answer, is_form_sumbited
@ -1741,7 +1741,11 @@ def tixcraft_ticket_main(driver, config_dict, ocr):
ocr_captcha_enable = config_dict["ocr_captcha"]["enable"] ocr_captcha_enable = config_dict["ocr_captcha"]["enable"]
ocr_captcha_with_submit = config_dict["ocr_captcha"]["auto_submit"] ocr_captcha_with_submit = config_dict["ocr_captcha"]["auto_submit"]
ocr_captcha_force_submit = config_dict["ocr_captcha"]["force_submit"] away_from_keyboard_enable = config_dict["ocr_captcha"]["force_submit"]
if not ocr_captcha_enable:
ocr_captcha_with_submit = False
if not ocr_captcha_with_submit:
away_from_keyboard_enable = False
if auto_check_agree: if auto_check_agree:
tixcraft_ticket_agree(driver) tixcraft_ticket_agree(driver)
@ -1802,13 +1806,15 @@ def tixcraft_ticket_main(driver, config_dict, ocr):
previous_answer = None previous_answer = None
is_verifyCode_editing = True is_verifyCode_editing = True
for redo_ocr in range(999): for redo_ocr in range(999):
is_need_redo_ocr, previous_answer, is_form_sumbited = tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, ocr_captcha_force_submit, previous_answer) is_need_redo_ocr, previous_answer, is_form_sumbited = tixcraft_auto_ocr(driver, ocr, ocr_captcha_with_submit, away_from_keyboard_enable, previous_answer)
if is_form_sumbited: if is_form_sumbited:
# start next loop. # start next loop.
is_verifyCode_editing = False is_verifyCode_editing = False
break break
if not ocr_captcha_force_submit:
if not away_from_keyboard_enable:
break break
if not is_need_redo_ocr: if not is_need_redo_ocr:
break break

View File

@ -19,7 +19,7 @@ import json
import webbrowser import webbrowser
import pyperclip import pyperclip
CONST_APP_VERSION = u"MaxBot (2023.01.13)" CONST_APP_VERSION = u"MaxBot (2023.01.13) ver.2"
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom" CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top" CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
@ -78,7 +78,7 @@ def load_translate():
en_us["pass_1_seat_remaining"] = 'Pass 1 seat remaining' en_us["pass_1_seat_remaining"] = 'Pass 1 seat remaining'
en_us["ocr_captcha"] = 'OCR captcha' en_us["ocr_captcha"] = 'OCR captcha'
en_us["ocr_captcha_with_submit"] = 'After guess auto submit' en_us["ocr_captcha_with_submit"] = 'After guess auto submit'
en_us["ocr_captcha_force_submit"] = 'Allow submit wrong answer' en_us["ocr_captcha_force_submit"] = 'Away from keyboard'
en_us["preference"] = 'Preference' en_us["preference"] = 'Preference'
en_us["advanced"] = 'Advanced' en_us["advanced"] = 'Advanced'
@ -136,7 +136,7 @@ def load_translate():
zh_tw["pass_1_seat_remaining"] = '避開「剩餘 1」的區域' zh_tw["pass_1_seat_remaining"] = '避開「剩餘 1」的區域'
zh_tw["ocr_captcha"] = '猜測驗證碼' zh_tw["ocr_captcha"] = '猜測驗證碼'
zh_tw["ocr_captcha_with_submit"] = '猜測後自動送出' zh_tw["ocr_captcha_with_submit"] = '猜測後自動送出'
zh_tw["ocr_captcha_force_submit"] = '允許送出錯的驗證碼' zh_tw["ocr_captcha_force_submit"] = '掛機模式'
zh_tw["preference"] = '偏好設定' zh_tw["preference"] = '偏好設定'
zh_tw["advanced"] = '進階設定' zh_tw["advanced"] = '進階設定'
@ -194,7 +194,7 @@ def load_translate():
zh_cn["pass_1_seat_remaining"] = '避开“剩余 1”的区域' zh_cn["pass_1_seat_remaining"] = '避开“剩余 1”的区域'
zh_cn["ocr_captcha"] = '猜测验证码' zh_cn["ocr_captcha"] = '猜测验证码'
zh_cn["ocr_captcha_with_submit"] = '猜测后自动送出' zh_cn["ocr_captcha_with_submit"] = '猜测后自动送出'
zh_cn["ocr_captcha_force_submit"] = '允许送出错的验证码' zh_cn["ocr_captcha_force_submit"] = '挂机模式'
zh_cn["preference"] = '偏好设定' zh_cn["preference"] = '偏好设定'
zh_cn["advanced"] = '進階設定' zh_cn["advanced"] = '進階設定'
@ -253,7 +253,7 @@ def load_translate():
ja_jp["pass_1_seat_remaining"] = '「1 席残り」エリアは避ける' ja_jp["pass_1_seat_remaining"] = '「1 席残り」エリアは避ける'
ja_jp["ocr_captcha"] = 'キャプチャを推測する' ja_jp["ocr_captcha"] = 'キャプチャを推測する'
ja_jp["ocr_captcha_with_submit"] = '提出で推測した後' ja_jp["ocr_captcha_with_submit"] = '提出で推測した後'
zh_cn["ocr_captcha_force_submit"] = '間違った回答の送信を許可する' zh_cn["ocr_captcha_force_submit"] = 'キーボードから離れて'
ja_jp["preference"] = '設定' ja_jp["preference"] = '設定'
ja_jp["advanced"] = '高度な設定' ja_jp["advanced"] = '高度な設定'