2023-06-15 add text server.

master
CHUN YU YAO 2023-06-16 00:31:46 +08:00
parent 1fca739a22
commit b0a4ef40c2
4 changed files with 37 additions and 10 deletions

View File

@ -99,6 +99,18 @@ def t_or_f(arg):
ret = True ret = True
return ret return ret
def format_config_keyword_for_json(user_input):
if len(user_input) > 0:
if not ('\"' in user_input):
user_input = '"' + user_input + '"'
if user_input[:1]=="{" and user_input[-1:]=="}"
user_input=user_input[1:]
user_input=user_input[:-]
if user_input[:1]=="[" and user_input[-1:]=="]"
user_input=user_input[1:]
user_input=user_input[:-]
return user_input
def sx(s1): def sx(s1):
key=18 key=18
return ''.join(chr(ord(a) ^ key) for a in s1) return ''.join(chr(ord(a) ^ key) for a in s1)
@ -2333,6 +2345,7 @@ def tixcraft_verify(driver, config_dict, answer_index):
presale_code = text_file.readline() presale_code = text_file.readline()
if len(presale_code) > 0: if len(presale_code) > 0:
presale_code = format_config_keyword_for_json(presale_code)
answer_list = json.loads("["+ presale_code +"]") answer_list = json.loads("["+ presale_code +"]")
if len(answer_list) > 0: if len(answer_list) > 0:
if answer_index < len(answer_list)-1: if answer_index < len(answer_list)-1:
@ -3818,12 +3831,16 @@ def kktix_reg_captcha(driver, config_dict, answer_index, is_finish_checkbox_clic
user_guess_string = "" user_guess_string = ""
if len(config_dict["advanced"]["user_guess_string"]) > 0: if len(config_dict["advanced"]["user_guess_string"]) > 0:
user_guess_string = config_dict["advanced"]["user_guess_string"] user_guess_string = config_dict["advanced"]["user_guess_string"]
# load from internet.
if len(user_guess_string) == 0: if len(user_guess_string) == 0:
if len(config_dict["advanced"]["online_dictionary_url"]) > 0: if len(config_dict["advanced"]["online_dictionary_url"]) > 0:
if os.path.exists(CONST_MAXBOT_ANSWER_ONLINE_FILE): if os.path.exists(CONST_MAXBOT_ANSWER_ONLINE_FILE):
with open(CONST_MAXBOT_ANSWER_ONLINE_FILE, "r") as text_file: with open(CONST_MAXBOT_ANSWER_ONLINE_FILE, "r") as text_file:
user_guess_string = text_file.readline() user_guess_string = text_file.readline()
if len(user_guess_string) > 0: if len(user_guess_string) > 0:
user_guess_string = format_config_keyword_for_json(user_guess_string)
answer_list = json.loads("["+ user_guess_string +"]") answer_list = json.loads("["+ user_guess_string +"]")
if len(answer_list) == 1: if len(answer_list) == 1:
inferred_answer_string = answer_list[0] inferred_answer_string = answer_list[0]

View File

@ -10,3 +10,4 @@ pyperclip
ddddocr ddddocr
urllib3>=1.21.1 urllib3>=1.21.1
numpy numpy
tornado

View File

@ -467,6 +467,18 @@ def load_translate():
translate['ja_jp']=ja_jp translate['ja_jp']=ja_jp
return translate return translate
def format_config_keyword_for_json(user_input):
if len(user_input) > 0:
if not ('\"' in user_input):
user_input = '"' + user_input + '"'
if user_input[:1]=="{" and user_input[-1:]=="}"
user_input=user_input[1:]
user_input=user_input[:-]
if user_input[:1]=="[" and user_input[-1:]=="]"
user_input=user_input[1:]
user_input=user_input[:-]
return user_input
def sx(s1): def sx(s1):
key=18 key=18
return ''.join(chr(ord(a) ^ key) for a in s1) return ''.join(chr(ord(a) ^ key) for a in s1)
@ -747,17 +759,13 @@ def btn_save_act(language_code, slience_mode=False):
config_dict["tixcraft"]["auto_reload_coming_soon_page"] = bool(chk_state_auto_reload_coming_soon_page.get()) config_dict["tixcraft"]["auto_reload_coming_soon_page"] = bool(chk_state_auto_reload_coming_soon_page.get())
area_keyword = txt_area_keyword.get("1.0",END).strip() area_keyword = txt_area_keyword.get("1.0",END).strip()
if len(area_keyword) > 0: area_keyword = format_config_keyword_for_json(area_keyword)
if not ('\"' in area_keyword):
area_keyword = '"' + area_keyword + '"'
area_keyword_exclude = txt_area_keyword_exclude.get("1.0",END).strip() area_keyword_exclude = txt_area_keyword_exclude.get("1.0",END).strip()
if len(area_keyword_exclude) > 0: area_keyword_exclude = format_config_keyword_for_json(area_keyword_exclude)
if not ('\"' in area_keyword_exclude):
area_keyword_exclude = '"' + area_keyword_exclude + '"'
user_guess_string = txt_user_guess_string.get("1.0",END).strip() user_guess_string = txt_user_guess_string.get("1.0",END).strip()
if len(user_guess_string) > 0: user_guess_string = format_config_keyword_for_json(user_guess_string)
if not ('\"' in user_guess_string):
user_guess_string = '"' + user_guess_string + '"'
config_dict["area_auto_select"]["enable"] = bool(chk_state_area_auto_select.get()) config_dict["area_auto_select"]["enable"] = bool(chk_state_area_auto_select.get())
config_dict["area_auto_select"]["mode"] = combo_area_auto_select_mode.get().strip() config_dict["area_auto_select"]["mode"] = combo_area_auto_select_mode.get().strip()

View File

@ -25,7 +25,8 @@ import asyncio
import tornado import tornado
from tornado.web import Application from tornado.web import Application
CONST_APP_VERSION = "MaxBot (2023.6.14)" CONST_APP_VERSION = "MaxBot (2023.6.15)"
CONST_SERVER_PORT = 8888 CONST_SERVER_PORT = 8888
def get_ip_address(): def get_ip_address():