Skip to content

Commit cc081ed

Browse files
committed
perf: 优化部分提示消息
1 parent 9363b5b commit cc081ed

File tree

6 files changed

+51
-17
lines changed

6 files changed

+51
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ git -C ./plugins/Yunzai-Kuro-Plugin/ pull
6161
建议通过 [锅巴插件](https://gitee.com/guoba-yunzai/guoba-plugin) 进行配置. 当然, 你也可以自己配置, 默认配置文件位置 `./data/system/default_config.json`, 配置文件位置 `./config/config.json`, 配置项作用:
6262

6363
```json
64-
// 此处的 json 可能忘记更新, 如果和实际的配置文件字段不同, qing'ji'sh
64+
// 此处的 json 可能忘记更新, 如果和实际的配置文件字段不同, 请及时反馈
6565
{
6666
"logger": { // 插件的日志器配置
6767
"logLevel": "info", // 日志等级, 可选值: trace, debug, info, warn, error, fatal
@@ -149,7 +149,7 @@ git -C ./plugins/Yunzai-Kuro-Plugin/ pull
149149
- [ ] 鸣潮
150150
- [ ] 战双
151151

152-
- [ ] 库街区战双游戏信息查询你
152+
- [ ] 库街区战双游戏信息查询
153153

154154
- [ ] 角色信息
155155

apps/kuroBBSLogin.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ export class kuroBBSLogin extends plugin {
3939
}
4040

4141
async captchaLoginHelp(e) {
42-
if (!e.isPrivate) {
43-
this.reply(`请私聊使用, 或使用 #库洛在线登录`)
44-
return false
45-
}
4642
let kuro = new kurologin(e)
4743
await kuro.captchaLoginHelp()
4844
return true
@@ -60,10 +56,6 @@ export class kuroBBSLogin extends plugin {
6056
}
6157

6258
async tokenLoginHelp(e) {
63-
if (!e.isPrivate) {
64-
this.reply(`请私聊使用, 或使用 #库洛在线登录`)
65-
return false
66-
}
6759
let kuro = new kurologin(e)
6860
await kuro.tokenLoginHelp()
6961
return true

model/kuroBBSLogin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class kuroBBSLogin {
2222
`建议优先使用 #库洛在线登录 , 无法使用可使用此功能`,
2323
this.captchaLoginHelpTip,
2424
'======== 登录步骤 ========',
25+
'注意, 同一个验证码可以多次使用, 所以请私聊发送!',
2526
`1. 前往 https://wiki.kurobbs.com/pns/home 点击右上角头像, 或下载安装库街区 APP 进入登录页面 \n2. 输入手机号点击发送验证码 \n3. 与 Bot 私聊, 将手机号和验证码用逗号隔开发送以完成绑定 \n \n例: 库洛账号18888888888,验证码114514`,
2627
`注意: 库街区 APP 同战双一样, 只能登录一个设备, 即机器人的登录和你自己手机 APP 的登录会互顶. 如果你需要用到库街区 APP, 请发送 #库洛token登录 查看抓包登录教程`,
2728
],
@@ -86,6 +87,7 @@ export default class kuroBBSLogin {
8687
`此方法允许你的手机与 Bot 使用相同的 token 以实现共存 \n需要 iOS 设备, 或者 ROOT 的 Android 设备, 如果没有请放弃并使用 #库洛在线登录`,
8788
this.tokenLoginHelpTip,
8889
'======== 登录步骤 ========',
90+
'高敏感登录方式, 请私聊使用!',
8991
`1. 根据抓包教程文章安装抓包软件并完成抓包: https://blog.tomys.top/2023-07/kuro-token/ \n2. 与 Bot 私聊, 将抓包获取到的 token 以 #库洛token后面跟上你的token 发送给 Bot 即可完成登录`,
9092
],
9193
'[库洛插件] 库洛 token 登录帮助'

model/mcGachaData.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,68 @@ export default class mcGachaData {
5353

5454
// 然后检查是否是通过链接上传的信息, 如果是链接上传就更新再生成, 如果是本地上传就直接生成
5555
if (gachaLink) {
56-
await this.e.reply(
56+
let willUpdateMsg = await this.e.reply(
5757
`QQ ${this.e.user_id} 的游戏 uid ${gameUid} 本地存在抽卡链接, 尝试更新抽卡记录...`
5858
)
59+
setTimeout(() => {
60+
if (willUpdateMsg) {
61+
try {
62+
if (this.e.group) this.e.group.recallMsg(willUpdateMsg.message_id)
63+
if (this.e.friend) this.e.friend.recallMsg(willUpdateMsg.message_id)
64+
} catch (err) {
65+
kuroLogger.warn('撤回消息失败:', JSON.stringify(err))
66+
}
67+
}
68+
}, 6000)
5969
let gachaRecord = await this.get(gachaLink, this.e.user_id)
6070
if (typeof gachaRecord === 'string') {
6171
// 如果记录更新失败, 进行提示; 如果更新成功, 不提示直接进入生成
62-
await this.e.reply(
72+
let updateFailMsg = await this.e.reply(
6373
`QQ ${this.e.user_id} 的游戏 uid ${gameUid} 更新抽卡记录失败: \n${failedReason} \n将展示历史抽卡记录 `
6474
)
75+
setTimeout(() => {
76+
if (updateFailMsg) {
77+
try {
78+
if (this.e.group) this.e.group.recallMsg(updateFailMsg.message_id)
79+
if (this.e.friend) this.e.friend.recallMsg(updateFailMsg.message_id)
80+
} catch (err) {
81+
kuroLogger.warn('撤回消息失败:', JSON.stringify(err))
82+
}
83+
}
84+
}, 6000)
6585
} else {
6686
// 更新成功, 存入本地
6787
let gachaUpdateRet = await this.update(this.e.user_id, gachaRecord)
6888
if (typeof gachaUpdateRet === 'string') {
69-
await this.e.reply(
89+
let saveFailedMsg = await this.e.reply(
7090
`QQ ${this.e.user_id} 的游戏 uid ${gameUid} 抽卡更新记录成功但保存失败: \n${gachaUpdateRet} \n将展示历史抽卡记录 `
7191
)
92+
setTimeout(() => {
93+
if (saveFailedMsg) {
94+
try {
95+
if (this.e.group) this.e.group.recallMsg(saveFailedMsg.message_id)
96+
if (this.e.friend) this.e.friend.recallMsg(saveFailedMsg.message_id)
97+
} catch (err) {
98+
kuroLogger.warn('撤回消息失败:', JSON.stringify(err))
99+
}
100+
}
101+
}, 6000)
72102
} // 更新且保存成功, 无需提示
73103
}
74104
} else {
75-
await this.e.reply(
105+
let localUploadedMsg = await this.e.reply(
76106
`QQ ${this.e.user_id} 的游戏 uid ${gameUid} 通过本地上传的抽卡记录, 将展示历史抽卡记录`
77107
)
108+
setTimeout(() => {
109+
if (localUploadedMsg) {
110+
try {
111+
if (this.e.group) this.e.group.recallMsg(localUploadedMsg.message_id)
112+
if (this.e.friend) this.e.friend.recallMsg(localUploadedMsg.message_id)
113+
} catch (err) {
114+
kuroLogger.warn('撤回消息失败:', JSON.stringify(err))
115+
}
116+
}
117+
}, 6000)
78118
}
79119

80120
if (tokenData && Object.keys(tokenData).length > 0) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yunzai-kuro-plugin",
3-
"version": "0.2.17-rel",
3+
"version": "0.2.18-dev",
44
"author": "TomyJan",
55
"description": "Yunzai-Bot plugin for kuro games.",
66
"type": "module",

0 commit comments

Comments
 (0)