@@ -101,6 +101,7 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
101101 if (permission.testPermission(contact.permitteeId).not () &&
102102 permission.testPermission(sender.permitteeId).not ()
103103 ) return
104+ val netdisk = contact.netdisk
104105
105106 launch {
106107 logger.info { " 发现文件消息 $content 开始上传" }
@@ -109,7 +110,7 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
109110 }
110111
111112 val rapid = try {
112- uploadAbsoluteFile(file)
113+ netdisk. uploadAbsoluteFile(file)
113114 } catch (cause: Exception ) {
114115 logger.warning({ " 上传失败 $file " }, cause)
115116 if (NetdiskUploadConfig .reply) {
@@ -132,23 +133,25 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
132133 public fun MessageEvent.save () {
133134 val plain = message.findIsInstance<PlainText >() ? : return
134135 if (permission.testPermission(sender.permitteeId).not ()) return
136+ val netdisk = sender.netdisk
135137
136138 launch {
137139 val paths = mutableListOf<String >()
138140 SHORT_URL_REGEX .findAll(plain.content).forEach { match ->
139141 logger.info { " 发现分享链接 ${match.value} 开始转存" }
140142 val (surl, password) = match.destructured
141- val path = sender. netdisk.saveShareLink(surl = surl, password = password)
143+ val path = netdisk.saveShareLink(surl = surl, password = password)
142144 paths.add(path)
143145
144146 launch {
145147 NetDiskFileSyncRecorder .record(source = source, surl = surl, password = password)
146148 }
147149 }
148- if (NetdiskUploadConfig .reply) {
150+ if (paths.isNotEmpty() && NetdiskUploadConfig .reply) {
151+ val info = netdisk.user()
149152 subject.sendMessage(buildMessageChain {
150153 append(message.quote())
151- appendLine(" 分享转存成功 " )
154+ appendLine(" 分享转存到 ${info.netdiskName} 成功 " )
152155 paths.forEach { path ->
153156 appendLine(path)
154157 }
@@ -160,17 +163,18 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
160163 STAND_CODE_REGEX .findAll(plain.content).forEach { match ->
161164 logger.info { " 发现秒传码 ${match.value} 开始保存" }
162165 val upload = RapidUploadInfo .parse(code = match.value)
163- val path = sender. netdisk.saveRapidUpload(upload = upload)
166+ val path = netdisk.saveRapidUpload(upload = upload)
164167 paths.add(path)
165168
166169 launch {
167170 NetDiskFileSyncRecorder .record(source = source, rapid = upload)
168171 }
169172 }
170- if (NetdiskUploadConfig .reply) {
173+ if (paths.isNotEmpty() && NetdiskUploadConfig .reply) {
174+ val info = netdisk.user()
171175 subject.sendMessage(buildMessageChain {
172176 append(message.quote())
173- appendLine(" 秒传码保存成功 " )
177+ appendLine(" 秒传码保存到 ${info.netdiskName} 成功 " )
174178 paths.forEach { path ->
175179 appendLine(path)
176180 }
@@ -184,18 +188,19 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
184188 val (base64) = match.destructured
185189 STAND_CODE_REGEX .findAll(base64.decodeBase64String()).forEach { m ->
186190 val upload = RapidUploadInfo .parse(code = m.value)
187- val path = sender. netdisk.saveRapidUpload(upload = upload)
191+ val path = netdisk.saveRapidUpload(upload = upload)
188192 paths.add(path)
189193
190194 launch {
191195 NetDiskFileSyncRecorder .record(source = source, rapid = upload)
192196 }
193197 }
194198 }
195- if (NetdiskUploadConfig .reply) {
199+ if (paths.isNotEmpty() && NetdiskUploadConfig .reply) {
200+ val info = netdisk.user()
196201 subject.sendMessage(buildMessageChain {
197202 append(message.quote())
198- appendLine(" 秒传链接保存成功 " )
203+ appendLine(" 秒传链接到 ${info.netdiskName} 保存成功 " )
199204 paths.forEach { path ->
200205 appendLine(path)
201206 }
@@ -205,7 +210,7 @@ public object NetDisk : BaiduNetDiskClient(config = NetdiskOauthConfig), Listene
205210 }
206211
207212 @PublishedApi
208- internal suspend fun uploadAbsoluteFile (file : AbsoluteFile ): RapidUploadInfo {
213+ internal suspend fun BaiduNetDiskClient. uploadAbsoluteFile (file : AbsoluteFile ): RapidUploadInfo {
209214 val url = requireNotNull(file.getUrl()) { " 远程文件 URL 获取失败" }
210215 @Suppress(" INVISIBLE_MEMBER" )
211216 val rapid = with (file) {
0 commit comments