Skip to content

Commit 69700d2

Browse files
committed
fix: reply info
1 parent 3225a3c commit 69700d2

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

  • src/main/kotlin/io/github/gnuf0rce/mirai/netdisk

src/main/kotlin/io/github/gnuf0rce/mirai/netdisk/NetDisk.kt

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,39 +133,55 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
133133
val plain = message.findIsInstance<PlainText>() ?: return
134134
if (permission.testPermission(sender.permitteeId).not()) return
135135

136-
SHORT_URL_REGEX.findAll(plain.content).forEach { match ->
137-
launch {
136+
launch {
137+
val paths = mutableListOf<String>()
138+
SHORT_URL_REGEX.findAll(plain.content).forEach { match ->
138139
logger.info { "发现分享链接 ${match.value} 开始转存" }
139140
val (surl, password) = match.destructured
140-
sender.netdisk.saveShareLink(surl = surl, password = password)
141+
val path = sender.netdisk.saveShareLink(surl = surl, password = password)
142+
paths.add(path)
141143

142144
launch {
143145
NetDiskFileSyncRecorder.record(source = source, surl = surl, password = password)
144146
}
145-
if (NetdiskUploadConfig.reply) {
146-
subject.sendMessage(message.quote() + "分享 $surl 转存成功")
147-
}
147+
}
148+
if (NetdiskUploadConfig.reply) {
149+
subject.sendMessage(buildMessageChain {
150+
append(message.quote())
151+
appendLine("分享转存成功")
152+
paths.forEach { path ->
153+
appendLine(path)
154+
}
155+
})
148156
}
149157
}
150-
STAND_CODE_REGEX.findAll(plain.content).forEach { match ->
151-
launch {
158+
launch {
159+
val paths = mutableListOf<String>()
160+
STAND_CODE_REGEX.findAll(plain.content).forEach { match ->
152161
logger.info { "发现秒传码 ${match.value} 开始保存" }
153162
val upload = RapidUploadInfo.parse(code = match.value)
154163
val path = sender.netdisk.saveRapidUpload(upload = upload)
164+
paths.add(path)
155165

156166
launch {
157167
NetDiskFileSyncRecorder.record(source = source, rapid = upload)
158168
}
159-
if (NetdiskUploadConfig.reply) {
160-
subject.sendMessage(message.quote() + "保存成功 $path")
161-
}
169+
}
170+
if (NetdiskUploadConfig.reply) {
171+
subject.sendMessage(buildMessageChain {
172+
append(message.quote())
173+
appendLine("秒传码保存成功")
174+
paths.forEach { path ->
175+
appendLine(path)
176+
}
177+
})
162178
}
163179
}
164-
BD_LINK_REGEX.findAll(plain.content).forEach { match ->
165-
launch {
180+
launch {
181+
val paths = mutableListOf<String>()
182+
BD_LINK_REGEX.findAll(plain.content).forEach { match ->
166183
logger.info { "发现秒传链接 ${match.value} 开始保存" }
167184
val (base64) = match.destructured
168-
val paths = mutableListOf<String>()
169185
STAND_CODE_REGEX.findAll(base64.decodeBase64String()).forEach { m ->
170186
val upload = RapidUploadInfo.parse(code = m.value)
171187
val path = sender.netdisk.saveRapidUpload(upload = upload)
@@ -175,9 +191,15 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
175191
NetDiskFileSyncRecorder.record(source = source, rapid = upload)
176192
}
177193
}
178-
if (NetdiskUploadConfig.reply) {
179-
subject.sendMessage(message.quote() + "保存成功 $paths")
180-
}
194+
}
195+
if (NetdiskUploadConfig.reply) {
196+
subject.sendMessage(buildMessageChain {
197+
append(message.quote())
198+
appendLine("秒传链接保存成功")
199+
paths.forEach { path ->
200+
appendLine(path)
201+
}
202+
})
181203
}
182204
}
183205
}

0 commit comments

Comments
 (0)