2024-03-13, update for kktix

master
Your Name 2024-03-29 17:29:39 +08:00
parent 1af47c122f
commit 859172b6dd
7 changed files with 240 additions and 174 deletions

View File

@ -19,6 +19,8 @@ import time
import warnings import warnings
import webbrowser import webbrowser
from datetime import datetime from datetime import datetime
import subprocess
import threading
import chromedriver_autoinstaller_max import chromedriver_autoinstaller_max
import requests import requests
@ -42,7 +44,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.03.12)" CONST_APP_VERSION = "MaxBot (2024.03.13)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -166,13 +168,12 @@ def encryptMe(s):
return data return data
def get_app_root(): def get_app_root():
# 讀取檔案裡的參數值 app_root = ""
basis = ""
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
basis = sys.executable basis = sys.executable
app_root = os.path.dirname(basis)
else: else:
basis = sys.argv[0] app_root = os.getcwd()
app_root = os.path.dirname(basis)
return app_root return app_root
def get_config_dict(args): def get_config_dict(args):
@ -191,9 +192,7 @@ def get_config_dict(args):
config_dict = json.load(json_data) config_dict = json.load(json_data)
if not args.headless is None: if not args.headless is None:
headless_flag = t_or_f(args.headless) config_dict["advanced"]["headless"] = t_or_f(args.headless)
if headless_flag:
config_dict["advanced"]["headless"] = True
if not args.homepage is None: if not args.homepage is None:
if len(args.homepage) > 0: if len(args.homepage) > 0:
@ -224,15 +223,14 @@ def get_config_dict(args):
config_dict["advanced"]["proxy_server_port"] = args.proxy_server config_dict["advanced"]["proxy_server_port"] = args.proxy_server
# special case for headless to enable away from keyboard mode. # special case for headless to enable away from keyboard mode.
is_headless_enable = False is_headless_enable_ocr = False
if config_dict["advanced"]["headless"]: if config_dict["advanced"]["headless"]:
# for tixcraft headless. # for tixcraft headless.
#print("If you are runnig headless mode on tixcraft, you need input your cookie SID.")
if len(config_dict["advanced"]["tixcraft_sid"]) > 1: if len(config_dict["advanced"]["tixcraft_sid"]) > 1:
is_headless_enable = True is_headless_enable_ocr = True
else:
print("If you are runnig headless mode on tixcraft, you need input your cookie SID.")
if is_headless_enable: if is_headless_enable_ocr:
config_dict["ocr_captcha"]["enable"] = True config_dict["ocr_captcha"]["enable"] = True
config_dict["ocr_captcha"]["force_submit"] = True config_dict["ocr_captcha"]["force_submit"] = True
@ -467,19 +465,15 @@ def get_chrome_options(webdriver_path, config_dict):
chrome_options.add_argument("--user-agent=%s" % (USER_AGENT)) chrome_options.add_argument("--user-agent=%s" % (USER_AGENT))
chrome_options.add_argument("--disable-animations") chrome_options.add_argument("--disable-animations")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--disable-infobars") chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-notifications") chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-popup-blocking") chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--disable-print-preview") chrome_options.add_argument("--disable-print-preview")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--disable-site-isolation-trials")
chrome_options.add_argument("--disable-smooth-scrolling") chrome_options.add_argument("--disable-smooth-scrolling")
chrome_options.add_argument("--disable-sync") chrome_options.add_argument("--disable-sync")
chrome_options.add_argument("--no-sandbox"); chrome_options.add_argument("--no-sandbox");
chrome_options.add_argument('--disable-features=TranslateUI') chrome_options.add_argument('--disable-features=TranslateUI')
chrome_options.add_argument('--disable-translate') chrome_options.add_argument('--disable-translate')
chrome_options.add_argument('--disable-web-security')
chrome_options.add_argument('--lang=zh-TW') chrome_options.add_argument('--lang=zh-TW')
# for navigator.webdriver # for navigator.webdriver
@ -715,19 +709,15 @@ def get_uc_options(uc, config_dict, webdriver_path):
options.add_argument("--user-agent=%s" % (USER_AGENT)) options.add_argument("--user-agent=%s" % (USER_AGENT))
options.add_argument("--disable-animations") options.add_argument("--disable-animations")
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_argument("--disable-infobars") options.add_argument("--disable-infobars")
options.add_argument("--disable-notifications") options.add_argument("--disable-notifications")
options.add_argument("--disable-popup-blocking") options.add_argument("--disable-popup-blocking")
options.add_argument("--disable-print-preview") options.add_argument("--disable-print-preview")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--disable-site-isolation-trials")
options.add_argument("--disable-smooth-scrolling") options.add_argument("--disable-smooth-scrolling")
options.add_argument("--disable-sync") options.add_argument("--disable-sync")
options.add_argument("--no-sandbox"); options.add_argument("--no-sandbox");
options.add_argument('--disable-features=TranslateUI') options.add_argument('--disable-features=TranslateUI')
options.add_argument('--disable-translate') options.add_argument('--disable-translate')
options.add_argument('--disable-web-security')
options.add_argument('--lang=zh-TW') options.add_argument('--lang=zh-TW')
options.add_argument("--password-store=basic") options.add_argument("--password-store=basic")
@ -877,6 +867,7 @@ def get_driver_by_config(config_dict):
print("platform:", platform.platform()) print("platform:", platform.platform())
print("homepage:", homepage) print("homepage:", homepage)
print("browser:", config_dict["browser"]) print("browser:", config_dict["browser"])
#print("headless:", config_dict["advanced"]["headless"])
#print("ticket_number:", str(config_dict["ticket_number"])) #print("ticket_number:", str(config_dict["ticket_number"]))
#print(config_dict["tixcraft"]) #print(config_dict["tixcraft"])
@ -3588,21 +3579,6 @@ def kktix_confirm_order_button(driver):
#print(exc) #print(exc)
pass pass
if not next_step_button is None:
is_visible = False
try:
if next_step_button.is_enabled():
is_visible = True
except Exception as exc:
pass
if is_visible:
try:
driver.execute_script("arguments[0].click();", next_step_button)
ret = True
except Exception as exc:
pass
return ret return ret
@ -7919,7 +7895,7 @@ def kktix_main(driver, url, config_dict, kktix_dict):
kktix_password = config_dict["advanced"]["kktix_password_plaintext"].strip() kktix_password = config_dict["advanced"]["kktix_password_plaintext"].strip()
if kktix_password == "": if kktix_password == "":
kktix_password = decryptMe(config_dict["advanced"]["kktix_password"]) kktix_password = decryptMe(config_dict["advanced"]["kktix_password"])
if len(kktix_account) > 4: if len(kktix_account) > 0:
kktix_login(driver, kktix_account, kktix_password) kktix_login(driver, kktix_account, kktix_password)
is_url_contain_sign_in = True is_url_contain_sign_in = True
@ -7957,8 +7933,23 @@ def kktix_main(driver, url, config_dict, kktix_dict):
kktix_dict["fail_list"] = [] kktix_dict["fail_list"] = []
kktix_dict["played_sound_ticket"] = False kktix_dict["played_sound_ticket"] = False
is_kktix_got_ticket = False
if '/events/' in url and '/registrations/' in url and "-" in url: if '/events/' in url and '/registrations/' in url and "-" in url:
if not '/registrations/new' in url: if not '/registrations/new' in url:
if not 'https://kktix.com/users/sign_in?' in url:
is_kktix_got_ticket = True
if is_kktix_got_ticket:
if '/events/' in config_dict["homepage"] and '/registrations/' in config_dict["homepage"] and "-" in config_dict["homepage"]:
# do nothing when second time come in.
if len(url.split('/'))>=7:
if len(config_dict["homepage"].split('/'))>=7:
# match event code.
if url.split('/')[4]==config_dict["homepage"].split('/')[4]:
# break loop.
is_kktix_got_ticket = False
if is_kktix_got_ticket:
if not kktix_dict["start_time"] is None: if not kktix_dict["start_time"] is None:
if not kktix_dict["done_time"] is None: if not kktix_dict["done_time"] is None:
bot_elapsed_time = kktix_dict["done_time"] - kktix_dict["start_time"] bot_elapsed_time = kktix_dict["done_time"] - kktix_dict["start_time"]
@ -7971,28 +7962,35 @@ def kktix_main(driver, url, config_dict, kktix_dict):
play_sound_while_ordering(config_dict) play_sound_while_ordering(config_dict)
if not kktix_dict["played_sound_order"]: if not kktix_dict["played_sound_order"]:
if len(config_dict["advanced"]["kktix_account"]) > 0: kktix_account = config_dict["advanced"]["kktix_account"]
print("搶票成功, 帳號:", config_dict["advanced"]["kktix_account"]) kktix_password = config_dict["advanced"]["kktix_password_plaintext"].strip()
print("基本資料與實名制網址:", url) if kktix_password == "":
kktix_password = decryptMe(config_dict["advanced"]["kktix_password"])
print("基本資料(或實名制)網址:", url)
if len(kktix_account) > 0:
print("搶票成功, 帳號:", kktix_account)
threading.Thread(target=launch_maxbot, args=("", url, kktix_account, kktix_password, "false", )).start()
driver.quit()
sys.exit()
kktix_dict["played_sound_order"] = True kktix_dict["played_sound_order"] = True
if config_dict["advanced"]["headless"]:
if config_dict["advanced"]["headless"]: if not kktix_dict["is_popup_checkout"]:
if not kktix_dict["is_popup_checkout"]: is_event_page = False
is_event_page = False if len(url.split('/'))>=7:
if len(url.split('/'))==8: is_event_page = True
is_event_page = True if is_event_page:
if is_event_page: confirm_clicked = kktix_confirm_order_button(driver)
confirm_clicked = kktix_confirm_order_button(driver) if confirm_clicked:
if confirm_clicked: domain_name = url.split('/')[2]
domain_name = url.split('/')[2] checkout_url = "https://%s/account/orders" % (domain_name)
checkout_url = "https://%s/account/orders" % (domain_name) print("搶票成功, 請前往該帳號訂單查看: %s" % (checkout_url))
print("搶票成功, 請前往該帳號訂單查看: %s" % (checkout_url)) webbrowser.open_new(checkout_url)
webbrowser.open_new(checkout_url) kktix_dict["is_popup_checkout"] = True
kktix_dict["is_popup_checkout"] = True driver.quit()
driver.quit() sys.exit()
sys.exit()
else: else:
kktix_dict["is_popup_checkout"] = False kktix_dict["is_popup_checkout"] = False
kktix_dict["played_sound_order"] = False kktix_dict["played_sound_order"] = False
@ -12589,13 +12587,63 @@ def resize_window(driver, config_dict):
target_array = config_dict["advanced"]["window_size"].split(",") target_array = config_dict["advanced"]["window_size"].split(",")
driver.set_window_size(int(target_array[0]), int(target_array[1])) driver.set_window_size(int(target_array[0]), int(target_array[1]))
def launch_maxbot(filename, homepage="", kktix_account = "", kktix_password="", headless=""):
cmd_argument = []
if len(filename) > 0:
cmd_argument.append('--input=' + filename)
if len(homepage) > 0:
cmd_argument.append('--homepage=' + homepage)
if len(kktix_account) > 0:
cmd_argument.append('--kktix_account=' + kktix_account)
if len(kktix_password) > 0:
cmd_argument.append('--kktix_password=' + kktix_password)
if len(headless) > 0:
cmd_argument.append('--headless=' + headless)
working_dir = os.path.dirname(os.path.realpath(__file__))
if hasattr(sys, 'frozen'):
print("execute in frozen mode")
# check platform here.
cmd = './chrome_tixcraft' + ' '.join(cmd_argument)
if platform.system() == 'Darwin':
print("execute MacOS python script")
if platform.system() == 'Linux':
print("execute linux binary")
if platform.system() == 'Windows':
print("execute .exe binary.")
cmd = 'chrome_tixcraft.exe ' + ' '.join(cmd_argument)
subprocess.Popen(cmd, shell=True, cwd=working_dir)
else:
interpreter_binary = 'python'
interpreter_binary_alt = 'python3'
if platform.system() != 'Windows':
interpreter_binary = 'python3'
interpreter_binary_alt = 'python'
print("execute in shell mode.")
script_name = "chrome_tixcraft"
try:
print('try', interpreter_binary)
cmd_array = [interpreter_binary, script_name + '.py'] + cmd_argument
s=subprocess.Popen(cmd_array, cwd=working_dir)
except Exception as exc:
print('try', interpreter_binary_alt)
try:
cmd_array = [interpreter_binary_alt, script_name + '.py'] + cmd_argument
s=subprocess.Popen(cmd_array, cwd=working_dir)
except Exception as exc:
msg=str(exc)
print("exeption:", msg)
pass
def main(args): def main(args):
config_dict = get_config_dict(args) config_dict = get_config_dict(args)
driver = None driver = None
if not config_dict is None: if not config_dict is None:
driver = get_driver_by_config(config_dict) driver = get_driver_by_config(config_dict)
resize_window(driver, config_dict) if not config_dict["advanced"]["headless"]:
resize_window(driver, config_dict)
else: else:
print("Load config error!") print("Load config error!")
@ -12794,9 +12842,9 @@ def cli():
help="overwrite ibonqware field", help="overwrite ibonqware field",
type=str) type=str)
#default="False",
parser.add_argument("--headless", parser.add_argument("--headless",
help="headless mode", help="headless mode",
default='False',
type=str) type=str)
parser.add_argument("--browser", parser.add_argument("--browser",

View File

@ -23,7 +23,7 @@ import sys
import threading import threading
import webbrowser import webbrowser
CONST_APP_VERSION = "MaxBot (2024.03.12)" CONST_APP_VERSION = "MaxBot (2024.03.13)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -135,12 +135,12 @@ def load_translate():
return translate return translate
def get_app_root(): def get_app_root():
basis = "" app_root = ""
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
basis = sys.executable basis = sys.executable
app_root = os.path.dirname(basis)
else: else:
basis = sys.argv[0] app_root = os.getcwd()
app_root = os.path.dirname(basis)
return app_root return app_root
@ -320,50 +320,52 @@ def btn_items_run_event(event):
filename=txt_file_name[btn_index-1].get().strip() filename=txt_file_name[btn_index-1].get().strip()
threading.Thread(target=launch_maxbot, args=(filename,)).start() threading.Thread(target=launch_maxbot, args=(filename,)).start()
def launch_maxbot(filename): def launch_maxbot(filename, homepage="", kktix_account = "", kktix_password=""):
if True: cmd_argument = []
working_dir = os.path.dirname(os.path.realpath(__file__)) if len(filename) > 0:
if hasattr(sys, 'frozen'): cmd_argument.append('--input=' + filename)
print("execute in frozen mode") if len(homepage) > 0:
cmd_argument.append('--homepage=' + homepage)
if len(kktix_account) > 0:
cmd_argument.append('--kktix_account=' + kktix_account)
if len(kktix_password) > 0:
cmd_argument.append('--kktix_password=' + kktix_password)
# check platform here. working_dir = os.path.dirname(os.path.realpath(__file__))
if platform.system() == 'Darwin': if hasattr(sys, 'frozen'):
print("execute MacOS python script") print("execute in frozen mode")
subprocess.Popen("./chrome_tixcraft --input %s" % (filename), shell=True, cwd=working_dir) # check platform here.
if platform.system() == 'Linux': cmd = './chrome_tixcraft' + ' '.join(cmd_argument)
print("execute linux binary") if platform.system() == 'Darwin':
subprocess.Popen("./chrome_tixcraft --input %s" % (filename), shell=True, cwd=working_dir) print("execute MacOS python script")
if platform.system() == 'Windows': if platform.system() == 'Linux':
print("execute .exe binary.") print("execute linux binary")
subprocess.Popen("chrome_tixcraft.exe --input %s" % (filename), shell=True, cwd=working_dir) if platform.system() == 'Windows':
else: print("execute .exe binary.")
interpreter_binary = 'python' cmd = 'chrome_tixcraft.exe ' + ' '.join(cmd_argument)
interpreter_binary_alt = 'python3' subprocess.Popen(cmd, shell=True, cwd=working_dir)
if platform.system() == 'Darwin': else:
# try python3 before python. interpreter_binary = 'python'
interpreter_binary = 'python3' interpreter_binary_alt = 'python3'
interpreter_binary_alt = 'python' if platform.system() != 'Windows':
print("execute in shell mode.") interpreter_binary = 'python3'
#print("script path:", working_dir) interpreter_binary_alt = 'python'
#messagebox.showinfo(title="Debug0", message=working_dir) print("execute in shell mode.")
# some python3 binary, running in 'python' command. script_name = "chrome_tixcraft"
try:
print('try', interpreter_binary)
cmd_array = [interpreter_binary, script_name + '.py'] + cmd_argument
s=subprocess.Popen(cmd_array, cwd=working_dir)
except Exception as exc:
print('try', interpreter_binary_alt)
try: try:
print('try', interpreter_binary) cmd_array = [interpreter_binary_alt, script_name + '.py'] + cmd_argument
s=subprocess.Popen([interpreter_binary, "chrome_tixcraft.py","--input", "%s" % (filename)], cwd=working_dir) s=subprocess.Popen(cmd_array, cwd=working_dir)
#s=subprocess.Popen(['./chrome_tixcraft'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=working_dir)
#s=subprocess.run(['python3', 'chrome_tixcraft.py'], cwd=working_dir)
#messagebox.showinfo(title="Debug1", message=str(s))
except Exception as exc: except Exception as exc:
print('try', interpreter_binary_alt) msg=str(exc)
try: print("exeption:", msg)
s=subprocess.Popen([interpreter_binary_alt, "chrome_tixcraft.py","--input", "%s" % (filename)], cwd=working_dir) pass
except Exception as exc:
msg=str(exc)
print("exeption:", msg)
#messagebox.showinfo(title="Debug2", message=msg)
pass
def ConfigListTab(root, config_dict, language_code, UI_PADDING_X): def ConfigListTab(root, config_dict, language_code, UI_PADDING_X):

View File

@ -11,7 +11,7 @@ import requests
import asyncio import asyncio
import nodriver as uc import nodriver as uc
CONST_APP_VERSION = "MaxBot (2024.03.12)" CONST_APP_VERSION = "MaxBot (2024.03.13)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
@ -34,12 +34,12 @@ def encryptMe(s):
return data return data
def get_app_root(): def get_app_root():
basis = "" app_root = ""
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
basis = sys.executable basis = sys.executable
app_root = os.path.dirname(basis)
else: else:
basis = sys.argv[0] app_root = os.getcwd()
app_root = os.path.dirname(basis)
return app_root return app_root
def load_json(): def load_json():

View File

@ -29,7 +29,7 @@ from datetime import datetime
import requests import requests
CONST_APP_VERSION = "MaxBot (2024.03.12)" CONST_APP_VERSION = "MaxBot (2024.03.13)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json" CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json"
@ -117,12 +117,12 @@ def t_or_f(arg):
return ret return ret
def get_app_root(): def get_app_root():
basis = "" app_root = ""
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
basis = sys.executable basis = sys.executable
app_root = os.path.dirname(basis)
else: else:
basis = sys.argv[0] app_root = os.getcwd()
app_root = os.path.dirname(basis)
return app_root return app_root
def load_json(): def load_json():
@ -348,49 +348,52 @@ def btn_items_run_event(event):
filename=txt_file_name[btn_index-1].get().strip() filename=txt_file_name[btn_index-1].get().strip()
threading.Thread(target=launch_maxbot, args=(filename,)).start() threading.Thread(target=launch_maxbot, args=(filename,)).start()
def launch_maxbot(filename): def launch_maxbot(filename, homepage="", kktix_account = "", kktix_password=""):
if True: cmd_argument = []
working_dir = os.path.dirname(os.path.realpath(__file__)) if len(filename) > 0:
if hasattr(sys, 'frozen'): cmd_argument.append('--input=' + filename)
print("execute in frozen mode") if len(homepage) > 0:
cmd_argument.append('--homepage=' + homepage)
if len(kktix_account) > 0:
cmd_argument.append('--kktix_account=' + kktix_account)
if len(kktix_password) > 0:
cmd_argument.append('--kktix_password=' + kktix_password)
# check platform here. working_dir = os.path.dirname(os.path.realpath(__file__))
if platform.system() == 'Darwin': if hasattr(sys, 'frozen'):
print("execute MacOS python script") print("execute in frozen mode")
subprocess.Popen("./chrome_tixcraft --input %s" % (filename), shell=True, cwd=working_dir) # check platform here.
if platform.system() == 'Linux': cmd = './chrome_tixcraft' + ' '.join(cmd_argument)
print("execute linux binary") if platform.system() == 'Darwin':
subprocess.Popen("./chrome_tixcraft --input %s" % (filename), shell=True, cwd=working_dir) print("execute MacOS python script")
if platform.system() == 'Windows': if platform.system() == 'Linux':
print("execute .exe binary.") print("execute linux binary")
subprocess.Popen("chrome_tixcraft.exe --input %s" % (filename), shell=True, cwd=working_dir) if platform.system() == 'Windows':
else: print("execute .exe binary.")
interpreter_binary = 'python' cmd = 'chrome_tixcraft.exe ' + ' '.join(cmd_argument)
interpreter_binary_alt = 'python3' subprocess.Popen(cmd, shell=True, cwd=working_dir)
if platform.system() == 'Darwin': else:
# try python3 before python. interpreter_binary = 'python'
interpreter_binary = 'python3' interpreter_binary_alt = 'python3'
interpreter_binary_alt = 'python' if platform.system() != 'Windows':
print("execute in shell mode.") interpreter_binary = 'python3'
#print("script path:", working_dir) interpreter_binary_alt = 'python'
#messagebox.showinfo(title="Debug0", message=working_dir) print("execute in shell mode.")
# some python3 binary, running in 'python' command. script_name = "chrome_tixcraft"
try:
print('try', interpreter_binary)
cmd_array = [interpreter_binary, script_name + '.py'] + cmd_argument
s=subprocess.Popen(cmd_array, cwd=working_dir)
except Exception as exc:
print('try', interpreter_binary_alt)
try: try:
print('try', interpreter_binary) cmd_array = [interpreter_binary_alt, script_name + '.py'] + cmd_argument
s=subprocess.Popen([interpreter_binary, "chrome_tixcraft.py","--input", "%s" % (filename)], cwd=working_dir) s=subprocess.Popen(cmd_array, cwd=working_dir)
#s=subprocess.Popen(['./chrome_tixcraft'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=working_dir)
#s=subprocess.run(['python3', 'chrome_tixcraft.py'], cwd=working_dir)
#messagebox.showinfo(title="Debug1", message=str(s))
except Exception as exc: except Exception as exc:
print('try', interpreter_binary_alt) msg=str(exc)
try: print("exeption:", msg)
s=subprocess.Popen([interpreter_binary_alt, "chrome_tixcraft.py","--input", "%s" % (filename)], cwd=working_dir) pass
except Exception as exc:
msg=str(exc)
print("exeption:", msg)
#messagebox.showinfo(title="Debug2", message=msg)
pass
def ConfigListTab(root, config_dict, language_code, UI_PADDING_X): def ConfigListTab(root, config_dict, language_code, UI_PADDING_X):

View File

@ -50,7 +50,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.03.12)" CONST_APP_VERSION = "MaxBot (2024.03.13)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -655,13 +655,12 @@ def is_arm():
return ret return ret
def get_app_root(): def get_app_root():
# 讀取檔案裡的參數值 app_root = ""
basis = ""
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
basis = sys.executable basis = sys.executable
app_root = os.path.dirname(basis)
else: else:
basis = sys.argv[0] app_root = os.getcwd()
app_root = os.path.dirname(basis)
return app_root return app_root
def get_default_config(): def get_default_config():
@ -1278,45 +1277,39 @@ def btn_preview_text_clicked():
def run_python_script(script_name): def run_python_script(script_name):
working_dir = os.path.dirname(os.path.realpath(__file__)) working_dir = os.path.dirname(os.path.realpath(__file__))
cmd_argument = ""
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
print("execute in frozen mode") print("execute in frozen mode")
cmd = './' + script_name + cmd_argument
# check platform here. # check platform here.
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
print("execute MacOS python script") print("execute MacOS python script")
subprocess.Popen("./" + script_name, shell=True, cwd=working_dir)
if platform.system() == 'Linux': if platform.system() == 'Linux':
print("execute linux binary") print("execute linux binary")
subprocess.Popen("./" + script_name, shell=True, cwd=working_dir)
if platform.system() == 'Windows': if platform.system() == 'Windows':
print("execute .exe binary.") print("execute .exe binary.")
subprocess.Popen(script_name + ".exe", shell=True, cwd=working_dir) cmd = script_name + ".exe" + cmd_argument
subprocess.Popen(cmd, shell=True, cwd=working_dir)
else: else:
interpreter_binary = 'python' interpreter_binary = 'python'
interpreter_binary_alt = 'python3' interpreter_binary_alt = 'python3'
if platform.system() == 'Darwin': if platform.system() != 'Windows':
# try python3 before python.
interpreter_binary = 'python3' interpreter_binary = 'python3'
interpreter_binary_alt = 'python' interpreter_binary_alt = 'python'
print("execute in shell mode.") print("execute in shell mode.")
#print("script path:", working_dir)
#messagebox.showinfo(title="Debug0", message=working_dir)
# some python3 binary, running in 'python' command. cmd = script_name + '.py'
try: try:
print('try', interpreter_binary) print('try', interpreter_binary)
s=subprocess.Popen([interpreter_binary, script_name + '.py'], cwd=working_dir) s=subprocess.Popen([interpreter_binary, cmd], cwd=working_dir)
#s=subprocess.Popen(['./chrome_tixcraft'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=working_dir)
#s=subprocess.run(['python3', 'chrome_tixcraft.py'], cwd=working_dir)
#messagebox.showinfo(title="Debug1", message=str(s))
except Exception as exc: except Exception as exc:
print('try', interpreter_binary_alt) print('try', interpreter_binary_alt)
try: try:
s=subprocess.Popen([interpreter_binary_alt, script_name + '.py'], cwd=working_dir) s=subprocess.Popen([interpreter_binary_alt, cmd], cwd=working_dir)
except Exception as exc: except Exception as exc:
msg=str(exc) msg=str(exc)
print("exeption:", msg) print("exeption:", msg)
#messagebox.showinfo(title="Debug2", message=msg)
pass pass
def btn_open_text_server_clicked(): def btn_open_text_server_clicked():

View File

@ -1,5 +1,6 @@
$("footer").remove(); $("footer").remove();
$("div.banner-wrapper div.img-wrapper img").remove(); $("div.banner-wrapper div.img-wrapper img").remove();
var myInterval = null; var myInterval = null;
//console.log("assign appear"); //console.log("assign appear");
@ -165,8 +166,12 @@ function begin()
let settings = JSON.parse($("#settings").html()); let settings = JSON.parse($("#settings").html());
let base_info = JSON.parse($("#base_info").html()); let base_info = JSON.parse($("#base_info").html());
let register_info = JSON.parse($("#register_info").html()); let register_info = JSON.parse($("#register_info").html());
$("#settings").remove();
$("#base_info").remove();
$("#register_info").remove();
//console.log(settings); //console.log(settings);
//console.log(register_info); //console.log(register_info);
kktix_area_keyword(settings, base_info, register_info); kktix_area_keyword(settings, base_info, register_info);
} }
@ -188,3 +193,5 @@ if(!dom_ready()) {
dom_ready(); dom_ready();
}, 100); }, 100);
} }

View File

@ -156,6 +156,18 @@ function kktix_event_register_info()
} }
} }
function kktix_force_auto_reload_by_timer()
{
if(settings) {
//console.log("auto reload for kktix");
if(settings.advanced.kktix_account.length > 0) {
setInterval(() => {
location.reload();;
}, 45 * 1000);
}
}
}
storage.get('settings', function (items) storage.get('settings', function (items)
{ {
if (items.settings) if (items.settings)
@ -169,7 +181,8 @@ storage.get('status', function (items)
if (items.status && items.status=='ON') if (items.status && items.status=='ON')
{ {
kktix_event_register_info(); kktix_event_register_info();
kktix_force_auto_reload_by_timer();
} else { } else {
console.log('no status found'); console.log('maxbot status is not ON');
} }
}); });