-
Notifications
You must be signed in to change notification settings - Fork 36
/
settings.py
1764 lines (1348 loc) · 97.5 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
#encoding=utf-8
try:
# for Python2
import tkMessageBox as messagebox
import ttk
from Tkinter import *
except ImportError:
# for Python3
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import base64
import datetime
import json
import os
import platform
import subprocess
import sys
import threading
import time
import webbrowser
CONST_APP_VERSION = "Max Interpark Bot (2023.09.02)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom"
CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top"
CONST_RANDOM = u"random"
CONST_SELECT_ORDER_DEFAULT = CONST_FROM_TOP_TO_BOTTOM
CONST_SELECT_OPTIONS_DEFAULT = (CONST_FROM_TOP_TO_BOTTOM, CONST_FROM_BOTTOM_TO_TOP, CONST_RANDOM)
CONST_HOMEPAGE_DEFAULT = "https://www.globalinterpark.com/"
URL_DONATE = 'https://max-everyday.com/about/#donate'
URL_HELP = 'https://max-everyday.com/2023/08/interpark-bot/'
URL_RELEASE = 'https://github.com/max32002/interpark_bot/releases'
URL_FB = 'https://www.facebook.com/maxbot.ticket'
CONST_OCR_CAPTCH_IMAGE_SOURCE_NON_BROWSER = "NonBrowser"
CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS = "canvas"
CONST_WEBDRIVER_TYPE_SELENIUM = "selenium"
CONST_WEBDRIVER_TYPE_UC = "undetected_chromedriver"
translate={}
def load_translate():
translate = {}
en_us={}
en_us["homepage"] = 'Homepage'
en_us["browser"] = 'Browser'
en_us["language"] = 'MaxBot Language'
en_us["locale"] = 'Interpark Locale'
en_us["enable"] = 'Enable'
en_us["date_auto_select"] = 'Date Auto Select'
en_us["date_select_order"] = 'Date select order'
en_us["date_keyword"] = 'Date Keyword'
en_us["keyword_usage"] = 'Each keyword need double quotes, separated by comma,\nUse space in keyword as AND logic.\nAppend ,\"\" to match all.'
en_us["time_auto_select"] = 'Time Auto Select'
en_us["time_select_order"] = 'Time select order'
en_us["time_keyword"] = 'Time Keyword'
en_us["keyword_exclude"] = 'Keyword Exclude'
en_us["user_info"] = "Payer Info"
en_us["user_name"] = "* Name"
en_us["user_date_of_birth"] = "Date of Birth"
en_us["user_email"] = "Email"
en_us["user_phone_number"] = "* Phone number"
en_us["user_cell_phone"] = "Cell phone"
en_us["payment_details"] = "Payment Details"
en_us["foreign_card"] = "Foreign Card"
en_us["credit_card_type"] = "Credit Card Type"
en_us["card_number"] = "Number"
en_us["card_exp"] = "Expiration (MM/YY)"
en_us["ocr_captcha"] = 'OCR captcha'
en_us["ocr_captcha_ddddocr_beta"] = 'ddddocr beta'
en_us["ocr_captcha_not_support_arm"] = 'ddddocr only supports Intel CPU'
en_us["verbose"] = 'Verbose mode'
en_us["running_status"] = 'Running Status'
en_us["running_url"] = 'Running URL'
en_us["status_idle"] = 'Idle'
en_us["status_paused"] = 'Paused'
en_us["status_enabled"] = 'Enabled'
en_us["status_running"] = 'Running'
en_us["idle"] = 'Idle'
en_us["resume"] = 'Resume'
en_us["preference"] = 'Preference'
en_us["advanced"] = 'Advanced'
en_us["autofill"] = 'Autofill'
en_us["runtime"] = 'Runtime'
en_us["about"] = 'About'
en_us["run"] = 'Run'
en_us["save"] = 'Save'
en_us["exit"] = 'Close'
en_us["copy"] = 'Copy'
en_us["restore_defaults"] = 'Restore Defaults'
en_us["done"] = 'Done'
en_us["interpark_account"] = 'interpark account'
en_us["interpark_password"] = 'interpark password'
en_us["facebook_account"] = 'Facebook account'
en_us["facebook_password"] = 'Facebook password'
en_us["save_password_alert"] = 'Saving passwords to config file may expose your passwords.'
en_us["maxbot_slogan"] = 'Max Interpark Bot is a FREE and open source bot program. Wish you booking successfully.'
en_us["donate"] = 'Donate'
en_us["help"] = 'Help'
en_us["release"] = 'Release'
zh_tw={}
zh_tw["homepage"] = '售票網站'
zh_tw["browser"] = '瀏覽器'
zh_tw["language"] = 'MaxBot 語言'
zh_tw["locale"] = 'Interpark 語言環境'
zh_tw["enable"] = '啟用'
zh_tw["date_auto_select"] = '日期自動點選'
zh_tw["date_select_order"] = '日期排序方式'
zh_tw["date_keyword"] = '日期關鍵字'
zh_tw["time_auto_select"] = '時間自動點選'
zh_tw["time_select_order"] = '時間排序方式'
zh_tw["time_keyword"] = '時間關鍵字'
zh_tw["keyword_exclude"] = '排除關鍵字'
zh_tw["keyword_usage"] = '每組關鍵字需要雙引號, 用逗號分隔, \n在關鍵字中使用空格作為 AND 邏輯。\n加入 ,\"\" 代表符合所有關鍵字'
zh_tw["user_info"] = "聯絡資訊"
zh_tw["user_name"] = "* 名字"
zh_tw["user_date_of_birth"] = "生日"
zh_tw["user_email"] = "Email"
zh_tw["user_phone_number"] = "* 聯絡電話"
zh_tw["user_cell_phone"] = "手機號碼"
zh_tw["payment_details"] = "信用卡持有人"
zh_tw["foreign_card"] = "非韓國信用卡"
zh_tw["credit_card_type"] = "信用卡類別"
zh_tw["card_number"] = "卡號"
zh_tw["card_exp"] = "到期日 (MM/YY)"
zh_tw["ocr_captcha"] = '猜測驗證碼'
zh_tw["ocr_captcha_ddddocr_beta"] = 'ddddocr beta'
zh_tw["ocr_captcha_not_support_arm"] = 'ocr 只支援 Intel CPU'
zh_tw["verbose"] = '輸出詳細除錯訊息'
zh_tw["running_status"] = '執行狀態'
zh_tw["running_url"] = '執行網址'
zh_tw["status_idle"] = '閒置中'
zh_tw["status_paused"] = '已暫停'
zh_tw["status_enabled"] = '已啟用'
zh_tw["status_running"] = '執行中'
zh_tw["idle"] = '暫停搶票'
zh_tw["resume"] = '接續搶票'
zh_tw["preference"] = '偏好設定'
zh_tw["advanced"] = '進階設定'
zh_tw["autofill"] = '自動填表單'
zh_tw["runtime"] = '執行階段'
zh_tw["about"] = '關於'
zh_tw["run"] = '搶票'
zh_tw["save"] = '存檔'
zh_tw["exit"] = '關閉'
zh_tw["copy"] = '複製'
zh_tw["restore_defaults"] = '恢復預設值'
zh_tw["done"] = '完成'
zh_tw["interpark_account"] = 'interpark 帳號'
zh_tw["interpark_password"] = 'interpark 密碼'
zh_tw["facebook_account"] = 'Facebook 帳號'
zh_tw["facebook_password"] = 'Facebook 密碼'
zh_tw["save_password_alert"] = '將密碼保存到設定檔中可能會讓您的密碼被盜。'
zh_tw["maxbot_slogan"] = 'Max Interpark Bot 是一個免費、開放原始碼的搶票機器人。\n祝您預訂成功。'
zh_tw["donate"] = '打賞'
zh_tw["release"] = '所有可用版本'
zh_tw["help"] = '使用教學'
zh_cn={}
zh_cn["homepage"] = '售票网站'
zh_cn["browser"] = '浏览器'
zh_cn["language"] = 'MaxBot 语言'
zh_cn["locale"] = 'Interpark 语言环境'
zh_cn["enable"] = '启用'
zh_cn["date_auto_select"] = '日期自动点选'
zh_cn["date_select_order"] = '日期排序方式'
zh_cn["date_keyword"] = '日期关键字'
zh_cn["time_auto_select"] = '时间自动点选'
zh_cn["time_select_order"] = '时间排序方式'
zh_cn["time_keyword"] = '时间关键字'
zh_cn["keyword_exclude"] = '排除关键字'
zh_cn["keyword_usage"] = '每组关键字需要双引号, 用逗号分隔, \n在关键字中使用空格作为 AND 逻辑。\n附加 ,\"\" 以匹配所有结果。'
zh_cn["user_info"] = "联络资讯"
zh_cn["user_name"] = "* 名字"
zh_cn["user_date_of_birth"] = "生日"
zh_cn["user_email"] = "Email"
zh_cn["user_phone_number"] = "* 联系电话"
zh_cn["user_cell_phone"] = "手机号码"
zh_cn["payment_details"] = "信用卡持有人"
zh_cn["foreign_card"] = "非韩国信用卡"
zh_cn["credit_card_type"] = "信用卡类别"
zh_cn["card_number"] = "卡号"
zh_cn["card_exp"] = "到期日 (MM/YY)"
zh_cn["ocr_captcha"] = '猜测验证码'
zh_cn["ocr_captcha_ddddocr_beta"] = 'ddddocr beta'
zh_cn["ocr_captcha_not_support_arm"] = 'ddddocr 仅支持 Intel CPU'
zh_cn["verbose"] = '输出详细除错讯息'
zh_cn["running_status"] = '执行状态'
zh_cn["running_url"] = '执行网址'
zh_cn["status_idle"] = '闲置中'
zh_cn["status_paused"] = '已暂停'
zh_cn["status_enabled"] = '已启用'
zh_cn["status_running"] = '执行中'
zh_cn["idle"] = '暂停抢票'
zh_cn["resume"] = '接续抢票'
zh_cn["preference"] = '偏好设定'
zh_cn["advanced"] = '进阶设定'
zh_cn["autofill"] = '自动填表单'
zh_cn["runtime"] = '运行'
zh_cn["about"] = '关于'
zh_cn["run"] = '抢票'
zh_cn["save"] = '存档'
zh_cn["exit"] = '关闭'
zh_cn["copy"] = '复制'
zh_cn["restore_defaults"] = '恢复默认值'
zh_cn["done"] = '完成'
zh_cn["interpark_account"] = 'interpark 帐号'
zh_cn["interpark_password"] = 'interpark 密码'
zh_cn["facebook_account"] = 'Facebook 帐号'
zh_cn["facebook_password"] = 'Facebook 密码'
zh_cn["save_password_alert"] = '将密码保存到文件中可能会暴露您的密码。'
zh_cn["maxbot_slogan"] = 'Max Interpark Bot 是一个免费的开源机器人程序。\n祝您预订成功。'
zh_cn["donate"] = '打赏'
zh_cn["help"] = '使用教学'
zh_cn["release"] = '所有可用版本'
ja_jp={}
ja_jp["homepage"] = 'ホームページ'
ja_jp["browser"] = 'ブラウザ'
ja_jp["language"] = 'MaxBot 言語'
ja_jp["locale"] = 'Interpark ロケール'
ja_jp["enable"] = '有効'
ja_jp["date_auto_select"] = '日付自動選択'
ja_jp["date_select_order"] = '日付のソート方法'
ja_jp["date_keyword"] = '日付キーワード'
ja_jp["time_auto_select"] = '时间自動選択'
ja_jp["time_select_order"] = '時間のソート方法'
ja_jp["time_keyword"] = '時間キーワード'
ja_jp["keyword_exclude"] = '除外キーワード'
ja_jp["keyword_usage"] = '各キーワードはカンマで区切られた二重引用符が必要です。\nキーワード内のスペースを AND ロジックとして使用します。\nすべてに一致するように ,\"\" を追加します。'
ja_jp["user_info"] = "聯絡資訊"
ja_jp["user_name"] = "* お名前"
ja_jp["user_date_of_birth"] = "生年月日"
ja_jp["user_email"] = "Email"
ja_jp["user_phone_number"] = "* 連絡可能な電話番号"
ja_jp["user_cell_phone"] = "携帯電話番号"
ja_jp["payment_details"] = "クレジットカード"
ja_jp["foreign_card"] = "海外発行カード"
ja_jp["credit_card_type"] = "クレジットカード類別"
ja_jp["card_number"] = "卡號"
ja_jp["card_exp"] = "到期日 (MM/YY)"
ja_jp["ocr_captcha"] = 'キャプチャを推測する'
ja_jp["ocr_captcha_ddddocr_beta"] = 'ddddocr beta'
ja_jp["ocr_captcha_not_support_arm"] = 'Intel CPU のみをサポートします'
ja_jp["verbose"] = '詳細モード'
ja_jp["running_status"] = 'スターテス'
ja_jp["running_url"] = '現在の URL'
ja_jp["status_idle"] = '閒置中'
ja_jp["status_paused"] = '一時停止'
ja_jp["status_enabled"] = '有効'
ja_jp["status_running"] = 'ランニング'
ja_jp["idle"] = 'アイドル'
ja_jp["resume"] = '再開する'
ja_jp["preference"] = '設定'
ja_jp["advanced"] = '高度な設定'
ja_jp["autofill"] = 'オートフィル'
ja_jp["runtime"] = 'ランタイム'
ja_jp["about"] = '情報'
ja_jp["run"] = 'チケットを取る'
ja_jp["save"] = '保存'
ja_jp["exit"] = '閉じる'
ja_jp["copy"] = 'コピー'
ja_jp["restore_defaults"] = 'デフォルトに戻す'
ja_jp["done"] = '終わり'
ja_jp["interpark_account"] = 'interparkのアカウント'
ja_jp["interpark_password"] = 'interparkのパスワード'
ja_jp["facebook_account"] = 'Facebookのアカウント'
ja_jp["facebook_password"] = 'Facebookのパスワード'
ja_jp["save_password_alert"] = 'パスワードをファイルに保存すると、パスワードが公開される可能性があります。'
ja_jp["maxbot_slogan"] = 'Max Interpark Bot は無料のオープン ソース ボット プログラムです。 予約が成功しますように。'
ja_jp["donate"] = '寄付'
ja_jp["help"] = '利用方法'
ja_jp["release"] = 'リリース'
translate['en_us']=en_us
translate['zh_tw']=zh_tw
translate['zh_cn']=zh_cn
translate['ja_jp']=ja_jp
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:]=="}":
tmp_json = {}
try:
tmp_json = json.loads(user_input)
key=list(tmp_json.keys())[0]
first_item=tmp_json[key]
user_input=json.dumps(first_item)
except Exception as exc:
pass
if user_input[:1]=="[" and user_input[-1:]=="]":
user_input=user_input[1:]
user_input=user_input[:-1]
return user_input
def sx(s1):
key=18
return ''.join(chr(ord(a) ^ key) for a in s1)
def decryptMe(b):
s=""
if(len(b)>0):
s=sx(base64.b64decode(b).decode("UTF-8"))
return s
def encryptMe(s):
data=""
if(len(s)>0):
data=base64.b64encode(sx(s).encode('UTF-8')).decode("UTF-8")
return data
def is_arm():
ret = False
if "-arm" in platform.platform():
ret = True
return ret
def get_app_root():
# 讀取檔案裡的參數值
basis = ""
if hasattr(sys, 'frozen'):
basis = sys.executable
else:
basis = sys.argv[0]
app_root = os.path.dirname(basis)
return app_root
def get_default_config():
config_dict = {}
config_dict["homepage"] = CONST_HOMEPAGE_DEFAULT
config_dict["browser"] = "chrome"
config_dict["language"] = "English"
config_dict["locale"] = "English"
config_dict["ocr_captcha"] = {}
config_dict["ocr_captcha"]["enable"] = True
config_dict["ocr_captcha"]["beta"] = True
config_dict["ocr_captcha"]["force_submit"] = True
config_dict["ocr_captcha"]["image_source"] = CONST_OCR_CAPTCH_IMAGE_SOURCE_CANVAS
config_dict["webdriver_type"] = CONST_WEBDRIVER_TYPE_UC
config_dict["date_auto_select"] = {}
config_dict["date_auto_select"]["enable"] = True
config_dict["date_auto_select"]["date_keyword"] = ""
config_dict["date_auto_select"]["mode"] = CONST_SELECT_ORDER_DEFAULT
config_dict["time_auto_select"] = {}
config_dict["time_auto_select"]["enable"] = True
config_dict["time_auto_select"]["time_keyword"] = ""
config_dict["time_auto_select"]["mode"] = CONST_SELECT_ORDER_DEFAULT
config_dict["keyword_exclude"] = "\"Restricted View\""
if is_arm():
config_dict["ocr_captcha"]["enable"] = False
config_dict["ocr_captcha"]["force_submit"] = False
today = datetime.date.today()
year = today.year
config_dict["user_name"] = ""
config_dict["user_date_of_birth_year"] = str(year - 20)
config_dict["user_date_of_birth_month"] = "01"
config_dict["user_date_of_birth_day"] = "01"
config_dict["user_phone_number"] = ""
config_dict["user_cell_phone"] = ""
config_dict["user_email"] = ""
config_dict["foreign_card"] = True
config_dict["credit_card_type"] = "Visa"
config_dict["cc_number"] = ""
config_dict["cc_exp_month"] = "01"
config_dict["cc_exp_year"] = str(year - 2000)
config_dict['advanced']={}
config_dict["advanced"]["facebook_account"] = ""
config_dict["advanced"]["facebook_password"] = ""
config_dict["advanced"]["interpark_account"] = ""
config_dict["advanced"]["interpark_password"] = ""
config_dict["advanced"]["adblock_plus_enable"] = False
config_dict["advanced"]["headless"] = False
config_dict["advanced"]["verbose"] = False
return config_dict
def read_last_url_from_file():
ret = ""
if os.path.exists(CONST_MAXBOT_LAST_URL_FILE):
with open(CONST_MAXBOT_LAST_URL_FILE, "r") as text_file:
ret = text_file.readline()
return ret
def load_json():
app_root = get_app_root()
# overwrite config path.
config_filepath = os.path.join(app_root, CONST_MAXBOT_CONFIG_FILE)
config_dict = None
if os.path.isfile(config_filepath):
with open(config_filepath) as json_data:
config_dict = json.load(json_data)
else:
config_dict = get_default_config()
return config_filepath, config_dict
def btn_restore_defaults_clicked(language_code):
app_root = get_app_root()
config_filepath = os.path.join(app_root, CONST_MAXBOT_CONFIG_FILE)
config_dict = get_default_config()
with open(config_filepath, 'w') as outfile:
json.dump(config_dict, outfile)
messagebox.showinfo(translate[language_code]["restore_defaults"], translate[language_code]["done"])
global root
load_GUI(root, config_dict)
def btn_idle_clicked(language_code):
app_root = get_app_root()
idle_filepath = os.path.join(app_root, CONST_MAXBOT_INT28_FILE)
with open(CONST_MAXBOT_INT28_FILE, "w") as text_file:
text_file.write("")
update_maxbot_runtime_status()
def btn_resume_clicked(language_code):
app_root = get_app_root()
idle_filepath = os.path.join(app_root, CONST_MAXBOT_INT28_FILE)
for i in range(10):
force_remove_file(idle_filepath)
update_maxbot_runtime_status()
def btn_save_clicked(language_code):
btn_save_act(language_code)
def format_time_string(data):
if not data is None:
data = data.replace(':',':')
return data
def btn_save_act(language_code, slience_mode=False):
app_root = get_app_root()
config_filepath = os.path.join(app_root, 'settings.json')
config_dict = get_default_config()
# read user input
global txt_homepage
global combo_browser
global combo_language
global txt_user_name
global combo_date_of_birth_year
global combo_date_of_birth_month
global combo_date_of_birth_day
global txt_user_email
global txt_user_phone_number
global txt_user_cell_phone
#global txt_card_number
#global txt_card_exp
global chk_state_foreign_card
global combo_credit_card_type
global txt_card_number_1
global txt_card_number_2
global txt_card_number_3
global txt_card_number_4
global combo_card_exp_month
global combo_card_exp_year
global chk_state_ocr_captcha
global chk_state_ocr_captcha_ddddocr_beta
global chk_state_verbose
global txt_facebook_account
global txt_facebook_password
global txt_interpark_account
global txt_interpark_password
global chk_state_date_auto_select
global txt_date_keyword
global chk_state_time_auto_select
global txt_time_keyword
global txt_keyword_exclude
global tabControl
is_all_data_correct = True
if is_all_data_correct:
#if combo_homepage.get().strip()=="":
if txt_homepage.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please enter homepage")
else:
#config_dict["homepage"] = combo_homepage.get().strip()
config_dict["homepage"] = txt_homepage.get().strip()
if is_all_data_correct:
if combo_browser.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please select a browser: chrome or firefox")
else:
config_dict["browser"] = combo_browser.get().strip()
if is_all_data_correct:
if combo_language.get().strip()=="":
is_all_data_correct = False
messagebox.showerror("Error", "Please select a language")
else:
config_dict["language"] = combo_language.get().strip()
# display as new language.
language_code = get_language_code_by_name(config_dict["language"])
if is_all_data_correct:
if txt_user_name.get().strip()=="":
is_all_data_correct = False
tabControl.select(1)
txt_user_name.focus_set()
messagebox.showerror("Error", "Please enter user name")
else:
config_dict["user_name"] = txt_user_name.get().strip()
if is_all_data_correct:
if txt_user_phone_number.get().strip()=="":
is_all_data_correct = False
tabControl.select(1)
txt_user_phone_number.focus_set()
messagebox.showerror("Error", "Please enter user phone number")
else:
config_dict["user_phone_number"] = txt_user_phone_number.get().strip()
if is_all_data_correct:
config_dict["user_date_of_birth_year"] = combo_date_of_birth_year.get().strip()
config_dict["user_date_of_birth_month"] = combo_date_of_birth_month.get().strip()
config_dict["user_date_of_birth_day"] = combo_date_of_birth_day.get().strip()
config_dict["user_email"] = txt_user_email.get().strip()
config_dict["foreign_card"] = bool(chk_state_foreign_card.get())
config_dict["credit_card_type"] = combo_credit_card_type.get().strip()
config_dict["user_cell_phone"] = txt_user_cell_phone.get().strip()
config_dict["cc_number"] = txt_card_number_1.get().strip() + txt_card_number_2.get().strip() + txt_card_number_3.get().strip() + txt_card_number_4.get().strip()
if len(config_dict["cc_number"]) > 0:
config_dict["cc_number"] = encryptMe(config_dict["cc_number"])
config_dict["cc_exp_month"] = combo_card_exp_month.get().strip()
config_dict["cc_exp_year"] = combo_card_exp_year.get().strip()
config_dict["advanced"]["facebook_account"] = txt_facebook_account.get().strip()
config_dict["advanced"]["facebook_password"] = txt_facebook_password.get().strip()
config_dict["advanced"]["facebook_password"] = encryptMe(config_dict["advanced"]["facebook_password"])
config_dict["advanced"]["interpark_account"] = txt_interpark_account.get().strip()
config_dict["advanced"]["interpark_password"] = txt_interpark_password.get().strip()
config_dict["advanced"]["interpark_password"] = encryptMe(config_dict["advanced"]["interpark_password"])
config_dict["ocr_captcha"] = {}
config_dict["ocr_captcha"]["enable"] = bool(chk_state_ocr_captcha.get())
config_dict["ocr_captcha"]["beta"] = bool(chk_state_ocr_captcha_ddddocr_beta.get())
if is_arm():
config_dict["ocr_captcha"]["enable"] = False
config_dict["ocr_captcha"]["force_submit"] = False
config_dict["advanced"]["verbose"] = bool(chk_state_verbose.get())
config_dict["date_auto_select"]["enable"] = bool(chk_state_date_auto_select.get())
config_dict["date_auto_select"]["mode"] = combo_date_auto_select_mode.get().strip()
date_keyword = txt_date_keyword.get("1.0",END).strip()
date_keyword = format_config_keyword_for_json(date_keyword)
config_dict["date_auto_select"]["date_keyword"]=date_keyword
config_dict["time_auto_select"]["enable"] = bool(chk_state_time_auto_select.get())
config_dict["time_auto_select"]["mode"] = combo_time_auto_select_mode.get().strip()
time_keyword = txt_time_keyword.get("1.0",END).strip()
time_keyword = format_config_keyword_for_json(time_keyword)
config_dict["time_auto_select"]["time_keyword"]=time_keyword
keyword_exclude = txt_keyword_exclude.get("1.0",END).strip()
keyword_exclude = format_config_keyword_for_json(keyword_exclude)
config_dict["keyword_exclude"]=keyword_exclude
# test keyword format.
if is_all_data_correct:
if len(date_keyword) > 0:
try:
test_array = json.loads("["+ date_keyword +"]")
except Exception as exc:
print(exc)
messagebox.showinfo(translate[language_code]["save"], "Error:" + translate[language_code]["date_keyword"])
is_all_data_correct = False
if is_all_data_correct:
if len(time_keyword) > 0:
try:
test_array = json.loads("["+ time_keyword +"]")
except Exception as exc:
print(exc)
messagebox.showinfo(translate[language_code]["save"], "Error:" + translate[language_code]["time_keyword"])
is_all_data_correct = False
if is_all_data_correct:
if len(keyword_exclude) > 0:
try:
test_array = json.loads("["+ keyword_exclude +"]")
except Exception as exc:
print(exc)
messagebox.showinfo(translate[language_code]["save"], "Error:" + translate[language_code]["keyword_exclude"])
is_all_data_correct = False
# save config.
if is_all_data_correct:
with open(config_filepath, 'w') as outfile:
json.dump(config_dict, outfile)
if slience_mode==False:
messagebox.showinfo(translate[language_code]["save"], translate[language_code]["done"])
return is_all_data_correct
def btn_run_clicked(language_code):
print('run button pressed.')
Root_Dir = ""
save_ret = btn_save_act(language_code, slience_mode=True)
print("save config result:", save_ret)
if save_ret:
threading.Thread(target=launch_maxbot).start()
def launch_maxbot():
working_dir = os.path.dirname(os.path.realpath(__file__))
print("working_dir:", working_dir)
if hasattr(sys, 'frozen'):
print("execute in frozen mode")
# check platform here.
if platform.system() == 'Darwin':
print("execute MacOS python script")
subprocess.Popen("./interpark_bot", shell=True, cwd=working_dir)
if platform.system() == 'Linux':
print("execute linux binary")
subprocess.Popen("./interpark_bot", shell=True, cwd=working_dir)
if platform.system() == 'Windows':
print("execute .exe binary.")
subprocess.Popen("interpark_bot.exe", shell=True, cwd=working_dir)
else:
interpreter_binary = 'python'
interpreter_binary_alt = 'python3'
if platform.system() == 'Darwin':
# try python3 before python.
interpreter_binary = 'python3'
interpreter_binary_alt = 'python'
print("execute in shell mode.")
#print("script path:", working_dir)
#messagebox.showinfo(title="Debug0", message=working_dir)
# some python3 binary, running in 'python' command.
try:
print('try', interpreter_binary)
s=subprocess.Popen([interpreter_binary, 'interpark_bot.py'], 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:
print('try', interpreter_binary_alt)
try:
s=subprocess.Popen([interpreter_binary_alt, 'interpark_bot.py'], cwd=working_dir)
except Exception as exc:
msg=str(exc)
print("exeption:", msg)
#messagebox.showinfo(title="Debug2", message=msg)
pass
def open_url(url):
webbrowser.open_new(url)
def btn_exit_clicked():
root.destroy()
def callbackLanguageOnChange(event):
applyNewLanguage()
def get_language_code_by_name(new_language):
language_code = "en_us"
if u'繁體中文' in new_language:
language_code = 'zh_tw'
if u'簡体中文' in new_language:
language_code = 'zh_cn'
if u'日本語' in new_language:
language_code = 'ja_jp'
#print("new language code:", language_code)
return language_code
def applyNewLanguage():
global combo_language
new_language = combo_language.get().strip()
#print("new language value:", new_language)
language_code=get_language_code_by_name(new_language)
global lbl_homepage
global lbl_browser
global lbl_language
global lbl_locale
global lbl_user_profile
global lbl_user_name
global lbl_user_date_of_birth
global lbl_user_email
global lbl_user_phone_number
global lbl_user_cell_phone
global lbl_payment_details
global lbl_foreign_card
global lbl_credit_card_type
global lbl_card_number
global lbl_card_exp
# for checkbox
global chk_foreign_card
global tabControl
global lbl_slogan
global lbl_help
global lbl_donate
global lbl_release
global lbl_ocr_captcha
global lbl_ocr_captcha_ddddocr_beta
global lbl_ocr_captcha_not_support_arm
global chk_ocr_captcha
global chk_ocr_captcha_ddddocr_beta
global lbl_verbose
global chk_verbose
global lbl_maxbot_status
global lbl_maxbot_last_url
lbl_homepage.config(text=translate[language_code]["homepage"])
lbl_browser.config(text=translate[language_code]["browser"])
lbl_language.config(text=translate[language_code]["language"])
lbl_locale.config(text=translate[language_code]["locale"])
lbl_user_profile.config(text=translate[language_code]["user_info"])
lbl_user_name.config(text=translate[language_code]["user_name"])
lbl_user_date_of_birth.config(text=translate[language_code]["user_date_of_birth"])
lbl_user_email.config(text=translate[language_code]["user_email"])
lbl_user_phone_number.config(text=translate[language_code]["user_phone_number"])
lbl_user_cell_phone.config(text=translate[language_code]["user_cell_phone"])
lbl_payment_details.config(text=translate[language_code]["payment_details"])
lbl_foreign_card.config(text=translate[language_code]["foreign_card"])
lbl_credit_card_type.config(text=translate[language_code]["credit_card_type"])
lbl_card_number.config(text=translate[language_code]["card_number"])
lbl_card_exp.config(text=translate[language_code]["card_exp"])
chk_foreign_card.config(text=translate[language_code]["enable"])
tabControl.tab(0, text=translate[language_code]["preference"])
tabControl.tab(1, text=translate[language_code]["autofill"])
tabControl.tab(2, text=translate[language_code]["advanced"])
tabControl.tab(3, text=translate[language_code]["runtime"])
tabControl.tab(4, text=translate[language_code]["about"])
lbl_slogan.config(text=translate[language_code]["maxbot_slogan"])
lbl_help.config(text=translate[language_code]["help"])
lbl_donate.config(text=translate[language_code]["donate"])
lbl_release.config(text=translate[language_code]["release"])
lbl_ocr_captcha.config(text=translate[language_code]["ocr_captcha"])
lbl_ocr_captcha_ddddocr_beta.config(text=translate[language_code]["ocr_captcha_ddddocr_beta"])
lbl_ocr_captcha_not_support_arm.config(text=translate[language_code]["ocr_captcha_not_support_arm"])
chk_ocr_captcha.config(text=translate[language_code]["enable"])
chk_ocr_captcha_ddddocr_beta.config(text=translate[language_code]["enable"])
lbl_verbose.config(text=translate[language_code]["verbose"])
chk_verbose.config(text=translate[language_code]["enable"])
lbl_maxbot_status.config(text=translate[language_code]["running_status"])
lbl_maxbot_last_url.config(text=translate[language_code]["running_url"])
global lbl_date_auto_select
global lbl_date_auto_select_mode
global lbl_date_keyword
global lbl_time_auto_select
global lbl_time_auto_select_mode
global lbl_time_keyword
global lbl_keyword_exclude
global lbl_keyword_usage
lbl_date_auto_select.config(text=translate[language_code]["date_auto_select"])
lbl_date_auto_select_mode.config(text=translate[language_code]["date_select_order"])
lbl_date_keyword.config(text=translate[language_code]["date_keyword"])
lbl_time_auto_select.config(text=translate[language_code]["time_auto_select"])
lbl_time_auto_select_mode.config(text=translate[language_code]["time_select_order"])
lbl_time_keyword.config(text=translate[language_code]["time_keyword"])
lbl_keyword_exclude.config(text=translate[language_code]["keyword_exclude"])
lbl_keyword_usage.config(text=translate[language_code]["keyword_usage"])
global lbl_facebook_account
global lbl_facebook_password
global lbl_interpark_account
global lbl_interpark_password
global lbl_save_password_alert
lbl_facebook_account.config(text=translate[language_code]["facebook_account"])
lbl_facebook_password.config(text=translate[language_code]["facebook_password"])
lbl_interpark_account.config(text=translate[language_code]["interpark_account"])
lbl_interpark_password.config(text=translate[language_code]["interpark_password"])
lbl_save_password_alert.config(text=translate[language_code]["save_password_alert"])
global btn_run
global btn_save
global btn_exit
global btn_restore_defaults
global btn_idle
global btn_resume
btn_run.config(text=translate[language_code]["run"])
btn_save.config(text=translate[language_code]["save"])
btn_exit.config(text=translate[language_code]["exit"])
btn_restore_defaults.config(text=translate[language_code]["restore_defaults"])
btn_idle.config(text=translate[language_code]["idle"])
btn_resume.config(text=translate[language_code]["resume"])
def btn_exit_clicked():
root.destroy()
# PS: nothing need to do, at current process.
def callbackUserGenderOnChange(event):
showHideBlocks()
# PS: nothing need to do, at current process.
def callbackHomepageOnChange(event):
showHideBlocks()
def showHideBlocks(all_layout_visible=False):
pass
def PreferenctTab(root, config_dict, language_code, UI_PADDING_X):
homepage_list = (CONST_HOMEPAGE_DEFAULT)
# output config:
print("config:", config_dict)
row_count = 0
frame_group_header = Frame(root)
group_row_count = 0
global lbl_homepage
lbl_homepage = Label(frame_group_header, text=translate[language_code]["homepage"])
lbl_homepage.grid(column=0, row=group_row_count, sticky = E)
'''
global combo_homepage
combo_homepage = ttk.Combobox(frame_group_header, state="readonly")
combo_homepage['values']= homepage_list
combo_homepage.set(homepage)
# PS: nothing need to do when on change event at this time.
combo_homepage.bind("<<ComboboxSelected>>", callbackHomepageOnChange)
combo_homepage.grid(column=1, row=group_row_count, sticky = W)
'''
global txt_homepage
txt_homepage_value = StringVar(frame_group_header, value=config_dict["homepage"])
txt_homepage = Entry(frame_group_header, width=30, textvariable = txt_homepage_value)
txt_homepage.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
global lbl_locale
lbl_locale = Label(frame_group_header, text=translate[language_code]['locale'])
lbl_locale.grid(column=0, row=group_row_count, sticky = E)
#global txt_locale
#txt_locale = Entry(root, width=30, textvariable = StringVar(root, value=locale))
#txt_locale.grid(column=1, row=group_row_count)
global combo_locale
combo_locale = ttk.Combobox(frame_group_header, state="readonly")
combo_locale['values']= ("English","한국어","中文","日本語")
#combo_locale.current(0)
combo_locale.set(config_dict['locale'])
combo_locale.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
global lbl_date_auto_select
lbl_date_auto_select = Label(frame_group_header, text=translate[language_code]['date_auto_select'])
lbl_date_auto_select.grid(column=0, row=group_row_count, sticky = E)
global chk_state_date_auto_select
chk_state_date_auto_select = BooleanVar()
chk_state_date_auto_select.set(config_dict["date_auto_select"]["enable"])
global chk_date_auto_select