refactor: 改一下, 避免覆盖原始消息 Id.

This commit is contained in:
LamGC 2024-01-11 21:17:44 +08:00
parent 8214e80d59
commit 431c8a34d8
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -49,13 +49,13 @@ object DefaultOneDriveTransferCallback : OneDriveTransferCallback {
.replyToMessageId(task.extra["messageId"].toString().toInt()) .replyToMessageId(task.extra["messageId"].toString().toInt())
.build() .build()
) )
task.extra["messageId"] = message.messageId task.extra["infoMessageId"] = message.messageId
} }
override fun onTransferStart(progress: OneDriveTransferWorkerProgress) { override fun onTransferStart(progress: OneDriveTransferWorkerProgress) {
val newMessage = EditMessageText.builder() val newMessage = EditMessageText.builder()
.chatId(progress.currentTask.extra["chatId"].toString().toLong()) .chatId(progress.currentTask.extra["chatId"].toString().toLong())
.messageId(progress.currentTask.extra["messageId"].toString().toInt()) .messageId(progress.currentTask.extra["infoMessageId"].toString().toInt())
.text( .text(
""" """
OneDrive 中转任务开始执行 OneDrive 中转任务开始执行
@ -65,14 +65,14 @@ object DefaultOneDriveTransferCallback : OneDriveTransferCallback {
) )
.build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt()) .build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt())
if (newMessage != null) { if (newMessage != null) {
progress.currentTask.extra["messageId"] = newMessage.messageId progress.currentTask.extra["infoMessageId"] = newMessage.messageId
} }
} }
override fun onProgress(progress: OneDriveTransferWorkerProgress) { override fun onProgress(progress: OneDriveTransferWorkerProgress) {
val newMessage = EditMessageText.builder() val newMessage = EditMessageText.builder()
.chatId(progress.currentTask.extra["chatId"].toString().toLong()) .chatId(progress.currentTask.extra["chatId"].toString().toLong())
.messageId(progress.currentTask.extra["messageId"].toString().toInt()) .messageId(progress.currentTask.extra["infoMessageId"].toString().toInt())
.text( .text(
""" """
OneDrive 中转任务执行中 OneDrive 中转任务执行中
@ -82,14 +82,14 @@ object DefaultOneDriveTransferCallback : OneDriveTransferCallback {
) )
.build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt()) .build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt())
if (newMessage != null) { if (newMessage != null) {
progress.currentTask.extra["messageId"] = newMessage.messageId progress.currentTask.extra["infoMessageId"] = newMessage.messageId
} }
} }
override fun onTransferFailure(task: OneDriveTransferTask, progress: OneDriveTransferWorkerProgress) { override fun onTransferFailure(task: OneDriveTransferTask, progress: OneDriveTransferWorkerProgress) {
val newMessage = EditMessageText.builder() val newMessage = EditMessageText.builder()
.chatId(task.extra["chatId"].toString().toLong()) .chatId(task.extra["chatId"].toString().toLong())
.messageId(task.extra["messageId"].toString().toInt()) .messageId(task.extra["infoMessageId"].toString().toInt())
.text( .text(
""" """
OneDrive 中转任务执行失败 OneDrive 中转任务执行失败
@ -99,14 +99,14 @@ object DefaultOneDriveTransferCallback : OneDriveTransferCallback {
) )
.build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt()) .build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt())
if (newMessage != null) { if (newMessage != null) {
progress.currentTask.extra["messageId"] = newMessage.messageId progress.currentTask.extra["infoMessageId"] = newMessage.messageId
} }
} }
override fun onTransferSuccess(task: OneDriveTransferTask, progress: OneDriveTransferWorkerProgress) { override fun onTransferSuccess(task: OneDriveTransferTask, progress: OneDriveTransferWorkerProgress) {
val newMessage = EditMessageText.builder() val newMessage = EditMessageText.builder()
.chatId(task.extra["chatId"].toString().toLong()) .chatId(task.extra["chatId"].toString().toLong())
.messageId(task.extra["messageId"].toString().toInt()) .messageId(task.extra["infoMessageId"].toString().toInt())
.text( .text(
""" """
OneDrive 中转任务执行成功 OneDrive 中转任务执行成功
@ -116,7 +116,7 @@ object DefaultOneDriveTransferCallback : OneDriveTransferCallback {
) )
.build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt()) .build().orSendMessage(progress.currentTask.bot, progress.currentTask.extra["messageId"].toString().toInt())
if (newMessage != null) { if (newMessage != null) {
progress.currentTask.extra["messageId"] = newMessage.messageId progress.currentTask.extra["infoMessageId"] = newMessage.messageId
} }
} }