add access token when call resetful API.

master
Your Name 2024-09-05 14:10:40 +08:00
parent cf444bc2e2
commit 7d6ff4330f
4 changed files with 45 additions and 34 deletions

View File

@ -10867,7 +10867,7 @@ def check_refresh_datetime_occur(driver, target_time):
return is_refresh_datetime_sent
def sendkey_to_browser(driver):
def sendkey_to_browser(driver, config_dict):
all_command_done = True
sendkey_dict = None
@ -10875,48 +10875,54 @@ def sendkey_to_browser(driver):
with open(CONST_MAXBOT_SENDKEY_FILE) as json_data:
sendkey_dict = json.load(json_data)
print(sendkey_dict)
#os.unlink(CONST_MAXBOT_SENDKEY_FILE)
except Exception as e:
print("error on open file")
print(e)
pass
is_command_accepted = False
if sendkey_dict:
if "command" in sendkey_dict:
for cmd_dict in sendkey_dict["command"]:
print("cmd_dict", cmd_dict)
if cmd_dict["type"] == "sendkey":
print("sendkey")
try:
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
form_input_1.clear()
form_input_1.click()
form_input_1.send_keys(cmd_dict["text"])
except Exception as exc:
all_command_done = False
print("error on sendkey")
print(exc)
pass
if cmd_dict["type"] == "click":
print("click")
try:
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
form_input_1.click()
except Exception as exc:
all_command_done = False
print("error on click")
print(exc)
pass
#print("cmd_dict", cmd_dict)
if cmd_dict["token"] == config_dict["token"]:
is_command_accepted = True
if cmd_dict["type"] == "sendkey":
print("sendkey")
try:
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
form_input_1.clear()
form_input_1.click()
form_input_1.send_keys(cmd_dict["text"])
except Exception as exc:
all_command_done = False
print("error on sendkey")
print(exc)
pass
if cmd_dict["type"] == "click":
print("click")
try:
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
form_input_1.click()
except Exception as exc:
all_command_done = False
print("error on click")
print(exc)
pass
time.sleep(0.05)
if all_command_done:
try:
os.unlink(CONST_MAXBOT_SENDKEY_FILE)
except Exception as e:
pass
if is_command_accepted:
if all_command_done:
try:
os.unlink(CONST_MAXBOT_SENDKEY_FILE)
except Exception as e:
pass
def main(args):
config_dict = get_config_dict(args)
config_dict["token"] = util.get_token()
driver = None
if not config_dict is None:
@ -10998,8 +11004,9 @@ def main(args):
continue
if os.path.exists(CONST_MAXBOT_SENDKEY_FILE):
sendkey_to_browser(driver)
sendkey_to_browser(driver, config_dict)
# default is 0, not reset.
if config_dict["advanced"]["reset_browser_interval"] > 0:
maxbot_running_time = time.time() - maxbot_last_reset_time
if maxbot_running_time > config_dict["advanced"]["reset_browser_interval"]:

View File

@ -12,6 +12,7 @@ import threading
from typing import Optional
import requests
import uuid
CONST_FROM_TOP_TO_BOTTOM = "from top to bottom"
CONST_FROM_BOTTOM_TO_TOP = "from bottom to top"
@ -2041,3 +2042,6 @@ def launch_maxbot(script_name="chrome_tixcraft", filename="", homepage="", kktix
msg=str(exc)
print("exeption:", msg)
pass
def get_token():
return str(uuid.uuid4().hex)

View File

@ -1 +1 @@
{"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "refresh_datetime": "", "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "max_dwell_time": 90}, "cityline": {"cityline_queue_retry": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_sound": {"ticket": true, "order": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "facebook_password_plaintext": "", "kktix_password_plaintext": "", "fami_password_plaintext": "", "urbtix_password_plaintext": "", "cityline_password_plaintext": "", "hkticketing_password_plaintext": "", "kham_password_plaintext": "", "ticket_password_plaintext": "", "udn_password_plaintext": "", "ticketplus_password_plaintext": "", "chrome_extension": true, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": false, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "auto_reload_overheat_count": 4, "auto_reload_overheat_cd": 1, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,0", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}}
{"homepage": "https://ticket.ibon.com.tw/EventBuy/B078PBP9/B07CE700/B07CE705", "browser": "chrome", "language": "English", "ticket_number": 2, "refresh_datetime": "", "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "max_dwell_time": 90}, "cityline": {"cityline_queue_retry": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_sound": {"ticket": true, "order": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "facebook_password_plaintext": "", "kktix_password_plaintext": "", "fami_password_plaintext": "", "urbtix_password_plaintext": "", "cityline_password_plaintext": "", "hkticketing_password_plaintext": "", "kham_password_plaintext": "", "ticket_password_plaintext": "", "udn_password_plaintext": "", "ticketplus_password_plaintext": "", "chrome_extension": true, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": false, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "auto_reload_overheat_count": 4, "auto_reload_overheat_cd": 1, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,0", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}, "token": "e08a643a0133424bb7cdc123b47c7857"}

View File

@ -113,8 +113,8 @@ async function ibon_set_ocr_answer_api(answer) {
let api_url = get_remote_url(settings);
let body = {
command: [
{type: 'sendkey', selector: "div.editor-box > div > input[type='text']", text: answer},
{type: 'click', selector: 'div#ticket-wrap a.btn.btn-primary[href]'}
{type: 'sendkey', selector: "div.editor-box > div > input[type='text']", text: answer, token: settings.token},
{type: 'click', selector: 'div#ticket-wrap a.btn.btn-primary[href]', token: settings.token}
]};
body = JSON.stringify(body);