-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathdjc_helper_tomb.py
6493 lines (5401 loc) · 261 KB
/
djc_helper_tomb.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
from __future__ import annotations
import datetime
import json
import math
import os
import random
import time
from typing import Any, Callable
from urllib.parse import quote_plus, unquote_plus
import requests
from config import AccountConfig, CommonConfig, config, load_config
from const import cached_dir, guanjia_skey_version
from dao import (
AmesvrCommonModRet,
AmesvrQueryFriendsInfo,
AmesvrQueryRole,
AmsActInfo,
BuyInfo,
DnfCollectionInfo,
GuanjiaNewLotteryResult,
GuanjiaNewQueryLotteryInfo,
GuanjiaNewRequest,
HuyaActTaskInfo,
HuyaUserTaskInfo,
IdeActInfo,
LuckyUserInfo,
LuckyUserTaskConf,
MoJieRenInfo,
MyHomeFarmInfo,
MyHomeFriendDetail,
MyHomeFriendList,
MyHomeGift,
MyHomeGiftList,
MyHomeInfo,
MyHomeValueGift,
RankUserInfo,
RoleInfo,
SailiyamWorkInfo,
SpringFuDaiInfo,
TemporaryChangeBindRoleInfo,
VoteEndWorkInfo,
VoteEndWorkList,
XinyueCatInfo,
XinyueCatInfoFromApp,
XinyueCatMatchResult,
XinyueCatUserInfo,
XinyueFinancingInfo,
XinyueWeeklyGiftInfo,
XinyueWeeklyGPointsInfo,
parse_amesvr_common_info,
)
from data_struct import to_raw_type
from db import DianzanDB, FireCrackersDB
from djc_helper import DjcHelper
from first_run import is_daily_first_run, is_first_run, is_weekly_first_run
from log import color, logger
from network import check_tencent_game_common_status_code, extract_qq_video_message
from qq_login import LoginResult, QQLogin
from qzone_activity import QzoneActivity
from setting import parse_card_group_info_map, zzconfig
from sign import getACSRFTokenForAMS, getMillSecondsUnix
from urls import get_act_url, get_not_ams_act, search_act
from urls_tomb import UrlsTomb
from usage_count import increase_counter
from util import (
async_message_box,
base64_encode,
format_time,
get_now_unix,
get_today,
json_compact,
md5,
now_after,
now_in_range,
parse_time,
parse_url_param,
range_from_one,
show_act_not_enable_warning,
show_end_time,
show_head_line,
tableify,
try_except,
uin2qq,
use_by_myself,
wait_for,
)
# 将几乎可以确定不再会重新上线的活动代码挪到这里,从而减少 djc_helper.py 的行数
class DjcHelperTomb:
local_saved_guanjia_openid_file = os.path.join(cached_dir, ".saved_guanjia_openid.{}.json")
def __init__(self, account_config, common_config, user_buy_info: BuyInfo | None = None):
self.cfg: AccountConfig = account_config
self.common_cfg: CommonConfig = common_config
# 初始化部分字段
self.lr: LoginResult | None = None
# 配置加载后,尝试读取本地缓存的skey
self.local_load_uin_skey()
# 初始化网络相关设置
self.init_network()
# 相关链接
self.urls = UrlsTomb()
self.user_buy_info = user_buy_info
self.zzconfig = zzconfig()
def expired_activities(self) -> list[tuple[str, Callable]]:
# re: 记得过期活动全部添加完后,一个个确认下确实过期了
return [
("qq会员杯", self.dnf_club_vip),
("集卡_旧版", self.ark_lottery),
("qq视频-AME活动", self.qq_video_amesvr),
("DNF十三周年庆活动", self.dnf_13),
("管家蚊子腿", self.guanjia),
("管家蚊子腿", self.guanjia_new),
("管家蚊子腿", self.guanjia_new_dup),
("DNF强者之路", self.dnf_strong),
("会员关怀", self.vip_mentor),
("会员关怀", self.dnf_vip_mentor),
("DNF福签大作战", self.dnf_fuqian),
("燃放爆竹活动", self.firecrackers),
("新春福袋大作战", self.spring_fudai),
("史诗之路来袭活动合集", self.dnf_1224),
("暖冬好礼活动", self.warm_winter),
("dnf漂流瓶", self.dnf_drift),
("阿拉德勇士征集令", self.dnf_warriors_call),
("DNF进击吧赛利亚", self.xinyue_sailiyam),
("2020DNF嘉年华页面主页面签到", self.dnf_carnival),
("dnf助手排行榜", self.dnf_rank),
("10月女法师三觉", self.dnf_female_mage_awaken),
("微信签到", self.wx_checkin),
("wegame国庆活动【秋风送爽关怀常伴】", self.wegame_guoqing),
("虎牙", self.huya),
("命运的抉择挑战赛", self.dnf_mingyun_jueze),
("轻松之路", self.dnf_relax_road),
("WeGameDup", self.dnf_wegame_dup),
("qq视频蚊子腿", self.qq_video),
("DNF名人堂", self.dnf_vote),
("DNF记忆", self.dnf_memory),
("关怀活动", self.dnf_guanhuai),
("DNF公会活动", self.dnf_gonghui),
("WeGame活动_新版", self.wegame_new),
("新职业预约活动", self.dnf_reserve),
("组队拜年", self.team_happy_new_year),
("hello语音(皮皮蟹)网页礼包兑换", self.hello_voice),
("翻牌活动", self.dnf_card_flip),
("DNF共创投票", self.dnf_dianzan),
("DNF互动站", self.dnf_interactive),
("心悦猫咪", self.xinyue_cat),
("黄钻", self.dnf_yellow_diamond),
("KOL", self.dnf_kol),
("幸运勇士", self.dnf_lucky_user),
("DNF集合站_ide", self.dnf_collection_ide),
("我的小屋", self.dnf_my_home),
("超享玩", self.super_core),
("DNF冒险家之路", self.dnf_maoxian_road),
("DNF闪光杯", self.dnf_shanguang),
("心悦app周礼包", self.xinyue_weekly_gift),
("dnf助手活动Dup", self.dnf_helper_dup),
("DNF集合站", self.dnf_collection),
("魔界人探险记", self.mojieren),
("巴卡尔大作战", self.dnf_bakaer_fight),
("巴卡尔对战地图", self.dnf_bakaer_map_ide),
("和谐补偿活动", self.dnf_compensate),
("DNF巴卡尔竞速", self.dnf_bakaer),
("冒险的起点", self.maoxian_start),
("心悦app理财礼卡", self.xinyue_financing),
("dnf周年拉好友", self.dnf_anniversary_friend),
("DNF心悦", self.dnf_xinyue),
("DNF心悦Dup", self.dnf_xinyue_dup),
("黑钻礼包", self.get_heizuan_gift),
("腾讯游戏信用礼包", self.get_credit_xinyue_gift),
("9163补偿", self.dnf_9163_apologize),
]
# --------------------------------------------9163补偿--------------------------------------------
@try_except()
def dnf_9163_apologize(self):
show_head_line("9163补偿")
self.show_amesvr_act_info(self.dnf_9163_apologize_op)
if not self.cfg.function_switches.get_dnf_9163_apologize or self.disable_most_activities():
show_act_not_enable_warning("9163补偿")
return
self.check_dnf_9163_apologize()
self.dnf_9163_apologize_op("领取9163礼包(2w代币券+2星辰百变部件)", "1014635", u_confirm=1)
async_message_box(
"3.30策划针对9163事件进行了说明,并提供了补偿礼盒,具体内容为20000欢乐代币券礼盒与及星辰百变部件礼盒(2个),小助手已帮你领取,可在绑定账号的邮箱查看",
"9163补偿",
show_once=True,
open_url="https://dnf.qq.com/webplat/info/news_version3/119/495/498/m21449/202403/950215.shtml",
)
def check_dnf_9163_apologize(self):
self.check_bind_account(
"9163补偿",
get_act_url("9163补偿"),
activity_op_func=self.dnf_9163_apologize_op,
query_bind_flowid="1014634",
commit_bind_flowid="1014633",
)
def dnf_9163_apologize_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_9163_apologize
return self.amesvr_request(
ctx,
"x6m5.ams.game.qq.com",
"group_3",
"dnf",
iActivityId,
iFlowId,
print_res,
get_act_url("9163补偿"),
**extra_params,
)
# --------------------------------------------DNF娱乐赛--------------------------------------------
def check_dnf_game(self):
self.check_bind_account(
"DNF娱乐赛",
get_act_url("DNF娱乐赛"),
activity_op_func=self.dnf_game_op,
query_bind_flowid="906057",
commit_bind_flowid="906056",
)
def dnf_game_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_game
return self.amesvr_request(
ctx,
"comm.ams.game.qq.com",
"group_k",
"bb",
iActivityId,
iFlowId,
print_res,
get_act_url("DNF娱乐赛"),
**extra_params,
)
# --------------------------------------------信用礼包--------------------------------------------
@try_except()
def get_credit_xinyue_gift(self):
show_head_line("腾讯游戏信用相关礼包")
self.show_not_ams_act_info("腾讯游戏信用礼包")
if not self.cfg.function_switches.get_credit_xinyue_gift or self.disable_most_activities():
show_act_not_enable_warning("腾讯游戏信用相关礼包")
return
self.get("每月信用星级礼包", self.urls.credit_gift)
try:
self.get("腾讯游戏信用-高信用即享礼包", self.urls.credit_xinyue_gift, gift_group=1)
# 等待一会
time.sleep(self.common_cfg.retry.request_wait_time)
self.get("腾讯游戏信用-高信用&游戏家即享礼包", self.urls.credit_xinyue_gift, gift_group=2)
except Exception as e:
logger.exception("腾讯游戏信用这个经常挂掉<_<不过问题不大,反正每月只能领一次", exc_info=e)
# --------------------------------------------黑钻--------------------------------------------
@try_except()
def get_heizuan_gift(self):
show_head_line("黑钻礼包")
self.show_not_ams_act_info("黑钻礼包")
if not self.cfg.function_switches.get_heizuan_gift or self.disable_most_activities():
show_act_not_enable_warning("每月黑钻等级礼包")
return
while True:
res = self.get("领取每月黑钻等级礼包", self.urls.heizuan_gift)
# note: 黑钻的活动页面不见了,现在没法手动绑定了,不再增加这个提示
# # 如果未绑定大区,提示前往绑定 "iRet": -50014, "sMsg": "抱歉,请先绑定大区后再试!"
# if res["iRet"] == -50014:
# self.guide_to_bind_account("每月黑钻等级礼包", get_act_url("黑钻礼包"), activity_op_func=None)
# continue
return res
# --------------------------------------------DNF心悦--------------------------------------------
@try_except()
def dnf_xinyue(self):
show_head_line("DNF心悦")
self.show_amesvr_act_info(self.dnf_xinyue_op)
if not self.cfg.function_switches.get_dnf_xinyue or self.disable_most_activities():
show_act_not_enable_warning("DNF心悦")
return
self.check_dnf_xinyue()
def jfAction(str_info, num):
str_arr = str_info.split("|")[1:-1]
result_list = []
for part in str_arr:
result_list.append(part.strip().split(" ")[num])
return result_list
def query_info() -> tuple[int, int, int]:
res = self.dnf_xinyue_op("输出数据", "952002", print_res=False)
raw_info = parse_amesvr_common_info(res)
xy_type = int(raw_info.sOutValue1)
temp_list = jfAction(raw_info.sOutValue2, 2)
total_step = int(temp_list[0]) # 总的步数
cj_ticket = int(temp_list[1]) # 抽奖券
return xy_type, total_step, cj_ticket
async_message_box(
"请手动前往 DPL职业联赛 活动页面进行报名PVP和PVE,可领取几个一次性的蚊子腿~。如果后续实际要参与鼻塞,对应周的排行奖励请自行领取",
"DPL职业联赛 报名",
open_url=get_act_url("DNF心悦"),
show_once=True,
)
# self.dnf_xinyue_op("报名礼包PVE", "964191")
# self.dnf_xinyue_op("报名礼包PVP", "964209")
self.dnf_xinyue_op("回流礼", "964201")
self.dnf_xinyue_op("心悦专属礼", "964206")
# self.dnf_xinyue_op("排行第1周", "964788")
# self.dnf_xinyue_op("排行第2周", "966444")
# self.dnf_xinyue_op("排行第3周", "966445")
# self.dnf_xinyue_op("排行第4周", "966446")
# self.dnf_xinyue_op("PVE排名奖励S", "966896")
# self.dnf_xinyue_op("PVE排名奖励A", "966910")
# self.dnf_xinyue_op("PVE排名奖励B", "966911")
# self.dnf_xinyue_op("通关领取", "964218")
# self.dnf_xinyue_op("全图鉴达成B级", "964219")
# self.dnf_xinyue_op("全图鉴达成A级", "964778")
# self.dnf_xinyue_op("全图鉴达成S级", "964780")
# self.dnf_xinyue_op("达成10个A级图鉴", "964781")
# self.dnf_xinyue_op("达成8个S级图鉴", "964782")
self.dnf_xinyue_op("参与一次怪物乱斗", "964198")
self.dnf_xinyue_op("登录心悦俱乐部App", "964202")
self.dnf_xinyue_op("消耗30点疲劳", "964203")
self.dnf_xinyue_op("加入游戏家俱乐部", "964204")
max_try = 4
for idx in range_from_one(max_try):
res = self.dnf_xinyue_op(f"{idx}/{max_try} 抽奖", "964196")
if res["ret"] == "700":
break
time.sleep(5)
def check_dnf_xinyue(self):
# re: 部分心悦活动,如DPL职业联赛报名后就不能修改绑定角色了,所以这里设定在已有绑定且与道聚城不一致的情况下,则不尝试修改绑定
act_can_change_bind = False
self.check_bind_account(
"DNF心悦",
get_act_url("DNF心悦"),
activity_op_func=self.dnf_xinyue_op,
query_bind_flowid="964189",
commit_bind_flowid="964188",
act_can_change_bind=act_can_change_bind,
)
def dnf_xinyue_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_xinyue
return self.amesvr_request(
ctx,
"act.game.qq.com",
"xinyue",
"tgclub",
iActivityId,
iFlowId,
print_res,
get_act_url("DNF心悦"),
**extra_params,
)
# --------------------------------------------DNF心悦Dup--------------------------------------------
@try_except()
def dnf_xinyue_dup(self):
show_head_line("DNF心悦Dup")
self.show_amesvr_act_info(self.dnf_xinyue_dup_op)
if not self.cfg.function_switches.get_dnf_xinyue or self.disable_most_activities():
show_act_not_enable_warning("DNF心悦Dup")
return
self.check_dnf_xinyue_dup()
def query_info() -> tuple[int, int, int, bool]:
res = self.dnf_xinyue_dup_op("输出数据", "952766", print_res=False)
raw_info = parse_amesvr_common_info(res)
lottery_ticket = int(raw_info.sOutValue3)
has_team = int(raw_info.sOutValue4) != 0
qdweek = raw_info.sOutValue5.split("|")
normal_sign_days = int(qdweek[0])
lucky_sign_days = int(qdweek[1])
return lottery_ticket, normal_sign_days, lucky_sign_days, has_team
_, normal_sign_days, lucky_sign_days, has_team = query_info()
if not has_team:
async_message_box(
"心悦俱乐部签到活动需要组队进行,请创建队伍或加入其他人的队伍。也可以按照稍后弹出的在线文档中的指引,与其他使用小助手的朋友进行组队~",
"23.6 心悦签到组队提醒",
show_once=True,
open_url="https://docs.qq.com/sheet/DYlNmcVhHQ2VXalhj?tab=BB08J2",
)
else:
self.dnf_xinyue_dup_op(f"7天签到 - {normal_sign_days}", "952789", today=normal_sign_days)
self.dnf_xinyue_dup_op(f"7天签到buff奖励 - {lucky_sign_days}", "952790", today=lucky_sign_days)
self.dnf_xinyue_dup_op("回流礼", "952777")
self.dnf_xinyue_dup_op("当日消耗疲劳值30", "953312")
self.dnf_xinyue_dup_op("当日充值6元", "953326")
self.dnf_xinyue_dup_op("登录DNF客户端", "952774")
self.dnf_xinyue_dup_op("消耗30点疲劳", "952779")
self.dnf_xinyue_dup_op("加入游戏家俱乐部", "952780")
lottery_ticket, _, _, _ = query_info()
logger.info(color("bold_cyan") + f"当前抽奖次数为 {lottery_ticket}")
for idx in range_from_one(lottery_ticket):
self.dnf_xinyue_dup_op(f"{idx}/{lottery_ticket} 抽奖", "952772")
time.sleep(5)
def check_dnf_xinyue_dup(self):
self.check_bind_account(
"DNF心悦Dup",
get_act_url("DNF心悦Dup"),
activity_op_func=self.dnf_xinyue_dup_op,
query_bind_flowid="952765",
commit_bind_flowid="952764",
)
def dnf_xinyue_dup_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_xinyue_dup
return self.amesvr_request(
ctx,
"act.game.qq.com",
"xinyue",
"tgclub",
iActivityId,
iFlowId,
print_res,
get_act_url("DNF心悦Dup"),
**extra_params,
)
# --------------------------------------------dnf周年拉好友--------------------------------------------
@try_except()
def dnf_anniversary_friend(self):
show_head_line("dnf周年拉好友")
self.show_amesvr_act_info(self.dnf_anniversary_friend_op)
if not self.cfg.function_switches.get_dnf_anniversary_friend or self.disable_most_activities():
show_act_not_enable_warning("dnf周年拉好友")
return
self.check_dnf_anniversary_friend()
self.dnf_anniversary_friend_op("分享领黑钻", "951475")
self.dnf_anniversary_friend_op("开启新旅程-领取同行奖励(主态)", "952931")
self.dnf_anniversary_friend_op("抽取光环", "952651")
self.dnf_anniversary_friend_op("每日任务-通关任意难度【110级地下城】1次", "951752")
self.dnf_anniversary_friend_op("每日任务-通关任意难度【110级地下城】3次", "952159")
self.dnf_anniversary_friend_op("每周任务-累计地下城获得【Lv105史诗装备】5件", "952160")
max_try_count = 4
for idx in range_from_one(max_try_count):
res = self.dnf_anniversary_friend_op(f"[{idx}/{max_try_count}] 抽奖", "952537")
if res["ret"] != "0":
break
self.dnf_anniversary_friend_op("随机点亮勇士印记", "952041")
def check_dnf_anniversary_friend(self):
self.check_bind_account(
"dnf周年拉好友",
get_act_url("dnf周年拉好友"),
activity_op_func=self.dnf_anniversary_friend_op,
query_bind_flowid="951473",
commit_bind_flowid="951472",
)
def dnf_anniversary_friend_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_anniversary_friend
return self.amesvr_request(
ctx,
"x6m5.ams.game.qq.com",
"group_3",
"dnf",
iActivityId,
iFlowId,
print_res,
get_act_url("dnf周年拉好友"),
**extra_params,
)
# --------------------------------------------心悦app理财礼卡--------------------------------------------
@try_except()
def xinyue_financing(self):
show_head_line("心悦app理财礼卡")
self.show_amesvr_act_info(self.xinyue_financing_op)
if not self.cfg.function_switches.get_xinyue_financing:
show_act_not_enable_warning("心悦app理财礼卡")
return
selectedCards = ["升级版月卡", "体验版月卡", "升级版周卡", "体验版周卡"]
logger.info(color("fg_bold_green") + f"当前设定的理财卡优先列表为: {selectedCards}")
type2name = {
"type1": "体验版周卡",
"type2": "升级版周卡",
"type3": "体验版月卡",
"type4": "升级版月卡",
}
# ------------- 封装函数 ----------------
def query_card_taken_map():
res = AmesvrCommonModRet().auto_update_config(
self.xinyue_financing_op("查询G分", "409361", print_res=False)["modRet"]
)
statusList = res.sOutValue3.split("|")
cardTakenMap = {}
for i in range(1, 4 + 1):
name = type2name[f"type{i}"]
if int(statusList[i]) > 0:
taken = True
else:
taken = False
cardTakenMap[name] = taken
return cardTakenMap
def show_financing_info():
info_map = get_financing_info_map()
heads, colSizes = zip(
("理财卡名称", 10),
("当前状态", 8),
("累计收益", 8),
("剩余天数", 8),
("结束日期", 10),
)
logger.info(color("bold_green") + tableify(heads, colSizes))
for name, info in info_map.items():
if name not in selectedCards:
# 跳过未选择的卡
continue
if info.buy:
status = "已购买"
else:
status = "未购买"
logger.info(
color("fg_bold_cyan")
+ tableify([name, status, info.totalIncome, info.leftTime, info.endTime], colSizes)
)
def get_financing_info_map():
financingInfoMap: dict = json.loads(
self.xinyue_financing_op("查询各理财卡信息", "409714", print_res=False)["modRet"]["jData"]["arr"]
)
financingTimeInfoMap: dict = json.loads(
self.xinyue_financing_op("查询理财礼卡天数信息", "409396", print_res=False)["modRet"]["jData"]["arr"]
)
info_map = {}
for typ, financingInfo in financingInfoMap.items():
info = XinyueFinancingInfo()
info.name = type2name[typ]
if financingInfo["status"] == 0:
info.buy = False
else:
info.buy = True
info.totalIncome = financingInfo["totalIncome"]
if typ in financingTimeInfoMap["alltype"]:
info.leftTime = financingTimeInfoMap["alltype"][typ]["leftime"]
if "opened" in financingTimeInfoMap and typ in financingTimeInfoMap["opened"]:
info.endTime = financingTimeInfoMap["opened"][typ]["endtime"]
info_map[info.name] = info
return info_map
# ------------- 正式逻辑 ----------------
gPoints = self.query_gpoints()
startPoints = gPoints
logger.info(f"当前G分为{startPoints}")
# 活动规则
# 1、购买理财礼卡:每次购买理财礼卡成功后,当日至其周期结束,每天可以领取相应的收益G分,当日如不领取,则视为放弃
# 2、购买限制:每个帐号仅可同时拥有两种理财礼卡,到期后则可再次购买
# ps:推荐购买体验版月卡和升级版月卡
financingCardsToBuyAndMap = {
# 名称 购买价格 购买FlowId 领取FlowId
"体验版周卡": (20, "408990", "507439"), # 5分/7天/35-20=15/2分收益每天
"升级版周卡": (80, "409517", "507441"), # 20分/7天/140-80=60/8.6分收益每天
"体验版月卡": (300, "409534", "507443"), # 25分/30天/750-300=450/15分收益每天
"升级版月卡": (600, "409537", "507444"), # 60分/30天/1800-600=1200/40分收益每天
}
cardInfoMap = get_financing_info_map()
cardTakenMap = query_card_taken_map()
for cardName in selectedCards:
if cardName not in financingCardsToBuyAndMap:
logger.warning(f"没有找到名为【{cardName}】的理财卡,请确认是否配置错误")
continue
buyPrice, buyFlowId, takeFlowId = financingCardsToBuyAndMap[cardName]
cardInfo = cardInfoMap[cardName]
taken = cardTakenMap[cardName]
# 如果尚未购买(或过期),则购买
if not cardInfo.buy:
if gPoints >= buyPrice:
self.xinyue_financing_op(f"购买{cardName}", buyFlowId)
gPoints -= buyPrice
else:
logger.warning(f"积分不够,将跳过购买~,购买{cardName}需要{buyPrice}G分,当前仅有{gPoints}G分")
continue
# 此处以确保购买,尝试领取
if taken:
logger.warning(f"今日已经领取过{cardName}了,本次将跳过")
else:
self.xinyue_financing_op(f"领取{cardName}", takeFlowId)
newGPoints = self.query_gpoints()
delta = newGPoints - startPoints
logger.warning("")
logger.warning(
color("fg_bold_yellow")
+ f"账号 {self.cfg.name} 本次心悦理财礼卡操作共获得 {delta} G分( {startPoints} -> {newGPoints} )"
)
logger.warning("")
show_financing_info()
logger.warning(
color("fg_bold_yellow")
+ "这个是心悦的活动,不是小助手的剩余付费时长,具体查看方式请读一遍付费指引/付费指引.docx"
)
@try_except(return_val_on_except=0, show_exception_info=False)
def query_gpoints(self):
res = AmesvrCommonModRet().auto_update_config(
self.xinyue_financing_op("查询G分", "409361", print_res=False)["modRet"]
)
return int(res.sOutValue2)
def xinyue_financing_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_xinyue_financing
plat = 3 # app
extraStr = quote_plus('"mod1":"1","mod2":"0","mod3":"x27"')
return self.amesvr_request(
ctx,
"comm.ams.game.qq.com",
"xinyue",
"tgclub",
iActivityId,
iFlowId,
print_res,
get_act_url("心悦app理财礼卡"),
plat=plat,
extraStr=extraStr,
**extra_params,
)
# --------------------------------------------冒险的起点--------------------------------------------
@try_except()
def maoxian_start(self):
show_head_line("冒险的起点")
self.show_amesvr_act_info(self.maoxian_start_op)
if not self.cfg.function_switches.get_maoxian_start or self.disable_most_activities():
show_act_not_enable_warning("冒险的起点")
return
self.maoxian_start_op("1", "919254")
self.maoxian_start_op("2", "919256")
self.maoxian_start_op("3", "919257")
self.maoxian_start_op("4", "919258")
self.maoxian_start_op("5", "919259")
self.maoxian_start_op("6", "919260")
self.maoxian_start_op("7", "919261")
def check_maoxian(self):
self.check_bind_account(
"冒险的起点",
get_act_url("冒险的起点"),
activity_op_func=self.maoxian_start_op,
query_bind_flowid="919251",
commit_bind_flowid="919250",
)
def maoxian_start_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_maoxian_start
return self.amesvr_request(
ctx,
"x6m5.ams.game.qq.com",
"group_3",
"dnf",
iActivityId,
iFlowId,
print_res,
get_act_url("冒险的起点"),
**extra_params,
)
# --------------------------------------------DNF巴卡尔竞速--------------------------------------------
@try_except()
def dnf_bakaer(self):
show_head_line("DNF巴卡尔竞速")
self.show_amesvr_act_info(self.dnf_bakaer_op)
if not self.cfg.function_switches.get_dnf_bakaer or self.disable_most_activities():
show_act_not_enable_warning("DNF巴卡尔竞速")
return
self.check_dnf_bakaer()
def query_info() -> tuple[int, int]:
res = self.dnf_bakaer_op("查询信息", "928267", print_res=False)
raw_info = parse_amesvr_common_info(res)
totat_lottery, current_lottery = raw_info.sOutValue3.split("|")
return int(totat_lottery), int(current_lottery)
async_message_box(
"请手动前往 巴卡尔竞速赛 活动页面进行报名~",
"巴卡尔竞赛报名",
open_url=get_act_url("DNF巴卡尔竞速"),
show_once=True,
)
today = get_today()
self.dnf_bakaer_op(f"7天签到 - {today}", "928281", today=today)
self.dnf_bakaer_op("见面礼", "928270")
self.dnf_bakaer_op("回流礼", "928446")
self.dnf_bakaer_op("心悦专属礼", "929712")
self.dnf_bakaer_op("绑定送竞猜票", "929213")
# 投票时间:3月3日0:00-3月17日23:59
if now_in_range("2023-03-03 00:00:00", "2023-03-10 00:00:00"):
async_message_box(
"当前处于巴卡尔竞速赛投票前半段时间,可手动前往活动页面选择你认为会是对应跨区冠军的主播或玩家。若未选择,将会在后半段投票时间随机投票",
"巴卡尔竞速赛投票提示",
open_url=get_act_url("DNF巴卡尔竞速"),
show_once=True,
)
elif now_in_range("2023-03-10 00:00:00", "2023-03-17 23:59:59"):
vote_id_name_list = [
# 斗鱼主播
(1, "银雪"),
(2, "亭宝"),
(3, "墨羽狼"),
(4, "素颜"),
(5, "泣雨"),
(6, "CEO"),
(7, "似雨幽离"),
(8, "丛雨"),
# 虎牙主播
(9, "狂人"),
(10, "小古子"),
(11, "小炜"),
(12, "云彩上的翅膀"),
(13, "东二梦想"),
(14, "猪猪侠神之手"),
(15, "仙哥哥"),
(16, "小勇"),
# 游戏家俱乐部
(17, "夜茶会"),
(18, "清幽茶语"),
(19, "今夕何年"),
(20, "黑色恋人"),
(21, "星梦"),
(22, "朝九晚五"),
(23, "天使赞歌"),
(24, "挚友"),
]
id, name = random.choice(vote_id_name_list)
logger.info(f"当前到达投票后半段时间,将尝试自动随机投一个 {id} {name}")
self.dnf_bakaer_op("竞猜", "928617", anchor=id)
# 领取时间:3月20日10:00~3月22日23:59
if now_in_range("2023-03-20 00:00:00", "2023-03-22 23:59:59"):
self.dnf_bakaer_op("竞猜礼包", "928628")
self.dnf_bakaer_op("登录DNF客户端", "928277")
self.dnf_bakaer_op("登录心悦俱乐部App", "928559")
self.dnf_bakaer_op("DNF在线时长30分钟", "928563")
self.dnf_bakaer_op("分享活动页面", "928570")
self.dnf_bakaer_op("进入活动页面", "928606")
totat_lottery, current_lottery = query_info()
logger.info(f"当前有{current_lottery}张抽奖券, 累积获得 {totat_lottery}")
for idx in range(current_lottery):
self.dnf_bakaer_op(f"第{idx + 1}/{current_lottery}次抽奖", "928273")
if idx != current_lottery:
time.sleep(5)
def check_dnf_bakaer(self, roleinfo=None, roleinfo_source="道聚城所绑定的角色"):
self.check_bind_account(
"DNF巴卡尔竞速",
get_act_url("DNF巴卡尔竞速"),
activity_op_func=self.dnf_bakaer_op,
query_bind_flowid="928266",
commit_bind_flowid="928265",
roleinfo=roleinfo,
roleinfo_source=roleinfo_source,
)
def dnf_bakaer_op(self, ctx, iFlowId, weekDay="", print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_bakaer
return self.amesvr_request(
ctx,
"act.game.qq.com",
"xinyue",
"tgclub",
iActivityId,
iFlowId,
print_res,
get_act_url("DNF巴卡尔竞速"),
**extra_params,
)
# --------------------------------------------和谐补偿活动--------------------------------------------
@try_except()
def dnf_compensate(self):
show_head_line("和谐补偿活动")
if not self.cfg.function_switches.get_dnf_compensate or self.disable_most_activities():
show_act_not_enable_warning("和谐补偿活动")
return
self.show_amesvr_act_info(self.dnf_compensate_op)
begin_time = "2023-02-23 10:00:00"
if now_after(begin_time):
res = self.dnf_compensate_op("初始化", "929083", print_res=False)
info = parse_amesvr_common_info(res)
if info.sOutValue1 != "1":
self.dnf_compensate_op("补偿奖励", "929042")
else:
logger.warning("已经领取过了,不再尝试")
else:
logger.warning(f"尚未到补偿领取时间 {begin_time}")
def dnf_compensate_op(self, ctx, iFlowId, print_res=True, **extra_params):
iActivityId = self.urls.iActivityId_dnf_compensate
roleinfo = self.get_dnf_bind_role()
checkInfo = self.get_dnf_roleinfo()
checkparam = quote_plus(quote_plus(checkInfo.checkparam))
return self.amesvr_request(
ctx,
"x6m5.ams.game.qq.com",
"group_3",
"dnf",
iActivityId,
iFlowId,
print_res,
get_act_url("和谐补偿活动"),
sRoleId=roleinfo.roleCode,
sRoleName=quote_plus(quote_plus(roleinfo.roleName)),
sArea=roleinfo.serviceID,
sAreaName=quote_plus(quote_plus(roleinfo.serviceName)),
ams_md5str=checkInfo.md5str,
ams_checkparam=checkparam,
**extra_params,
)
# --------------------------------------------巴卡尔对战地图--------------------------------------------
@try_except()
def dnf_bakaer_map_ide(self):
show_head_line("巴卡尔对战地图")
self.show_not_ams_act_info("巴卡尔对战地图")
if not self.cfg.function_switches.get_dnf_bakaer_map or self.disable_most_activities():
show_act_not_enable_warning("巴卡尔对战地图")
return
self.check_dnf_bakaer_map_ide()
self.dnf_bakaer_map_ide_op("领取登录礼包", "164862")
self.dnf_bakaer_map_ide_op("领取新春地下城礼包", "164879")
def check_dnf_bakaer_map_ide(self, **extra_params):
return self.ide_check_bind_account(
"巴卡尔对战地图",
get_act_url("巴卡尔对战地图"),
activity_op_func=self.dnf_bakaer_map_ide_op,
sAuthInfo="",
sActivityInfo="",
)
def dnf_bakaer_map_ide_op(
self,
ctx: str,
iFlowId: str,
print_res=True,
**extra_params,
):
iActivityId = self.urls.ide_iActivityId_dnf_bakaer_map
return self.ide_request(
ctx,
"comm.ams.game.qq.com",
iActivityId,
iFlowId,
print_res,
get_act_url("巴卡尔对战地图"),
**extra_params,
)
# --------------------------------------------巴卡尔大作战--------------------------------------------
@try_except()
def dnf_bakaer_fight(self):
show_head_line("巴卡尔大作战")
self.show_amesvr_act_info(self.dnf_bakaer_fight_op)
if not self.cfg.function_switches.get_dnf_bakaer_fight or self.disable_most_activities():
show_act_not_enable_warning("巴卡尔大作战")
return
self.check_dnf_bakaer_fight()
boss_info_list = [
("邪龙", 1),
("狂龙", 3),
("冰龙", 2),
# ("巴卡尔", 4),
]
self.dnf_bakaer_fight_op("选取boss - 优先尝试巴卡尔", "917673", bossId="4")
# 然后打乱顺序,依次尝试选取各个boss
random.shuffle(boss_info_list)
for name, id in boss_info_list:
time.sleep(3)
self.dnf_bakaer_fight_op(f"选取boss - {name}", "917673", bossId=id)
# 个人任务
self.dnf_bakaer_fight_op("完成登录游戏任务击杀boss", "918026")
self.dnf_bakaer_fight_op("消耗疲劳值击杀boss", "918098")
self.dnf_bakaer_fight_op("每日通关推荐地下城", "918099")
self.dnf_bakaer_fight_op("在线30分钟", "918100")
# 组队任务
self.dnf_bakaer_fight_op("组队--分享任务", "918108")
self.dnf_bakaer_fight_op("组队通关-毁坏的寂静城", "918109")
self.dnf_bakaer_fight_op("组队通关-天界实验室", "918110")
self.dnf_bakaer_fight_op("组队通关-110级副本", "918111")
self.dnf_bakaer_fight_op("掉落邪龙", "918119")
self.dnf_bakaer_fight_op("掉落冰龙", "918120")
self.dnf_bakaer_fight_op("掉落狂龙", "918121")
self.dnf_bakaer_fight_op("掉落巴卡尔", "918122")
# 奖励提示自行领取
async_message_box(
(
"巴卡尔大作战活动请自行创建攻坚队,或者加入他人的攻坚队,来完成初始流程,否则活动不能正常操作\n"