MCPcopy Create free account
hub / github.com/Loping151/RoverSign / open_switch_func

Function open_switch_func

RoverSign/roversign_config/__init__.py:29–97  ·  view source on GitHub ↗
(bot: Bot, ev: Event)

Source from the content-addressed store, hash-verified

27""",
28)
29async def open_switch_func(bot: Bot, ev: Event):
30 if ev.text == "战双自动签到":
31 return await _handle_pgr_switch(bot, ev)
32 if ev.text not in ("自动签到", "鸣潮自动签到"):
33 return
34
35 ev.text = "鸣潮自动签到"
36
37 at_sender = True if ev.group_id else False
38 uid = await WavesBind.get_uid_by_game(ev.user_id, ev.bot_id)
39 if uid is None:
40 msg = f"您还未绑定鸣潮特征码, 请使用【{PREFIX}绑定uid】完成绑定!"
41 return await bot.send(
42 (" " if at_sender else "") + msg,
43 at_sender,
44 )
45
46 from ..utils.rover_api import rover_api
47
48 token = await rover_api.get_self_waves_ck(uid, ev.user_id, ev.bot_id)
49 if not token:
50 from ..utils.errors import WAVES_CODE_101_MSG
51
52 user_pref = await get_hide_uid_pref(
53 uid,
54 ev.user_id,
55 ev.bot_id,
56 game_id=WAVES_GAME_ID,
57 )
58 msg = (
59 f"当前特征码:{hide_uid(uid, user_pref=user_pref)}\n"
60 f"{WAVES_CODE_101_MSG.rstrip(chr(10))}"
61 )
62 return await bot.send((" " if at_sender else "") + msg, at_sender)
63
64 logger.info(f"[库洛签到·配置] user_id={ev.user_id} 尝试[{ev.command[0:2]}]了[{ev.text}]功能")
65
66 im = await set_config_func(ev, uid)
67
68 # 补充处理战双(PGR)的所有有效UID
69 pgr_uid_list = await WavesBind.get_uid_list_by_game(
70 ev.user_id, ev.bot_id, game_name="pgr"
71 )
72 pgr_done = False
73 if pgr_uid_list:
74 if "开启" in ev.command:
75 option = ev.group_id if ev.group_id else "on"
76 else:
77 option = "off"
78 for pgr_uid in pgr_uid_list:
79 pgr_user = await WavesUser.select_waves_user(
80 pgr_uid, ev.user_id, ev.bot_id, game_id=PGR_GAME_ID
81 )
82 if pgr_user and pgr_user.cookie and pgr_user.status != "无效":
83 await WavesUser.update_data_by_uid(
84 uid=pgr_uid,
85 bot_id=ev.bot_id,
86 sign_switch=option,

Callers

nothing calls this directly

Calls 6

_handle_pgr_switchFunction · 0.85
get_hide_uid_prefFunction · 0.85
hide_uidFunction · 0.85
set_config_funcFunction · 0.85
get_self_waves_ckMethod · 0.80
select_waves_userMethod · 0.80

Tested by

no test coverage detected