mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
use coroutines
This commit is contained in:
parent
3e03d4782d
commit
210609bd7b
@ -3,6 +3,7 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
|||||||
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.json.JsonArray
|
import kotlinx.serialization.json.JsonArray
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
@ -23,8 +24,6 @@ import moe.fuqiuluo.shamrock.tools.asString
|
|||||||
import moe.fuqiuluo.shamrock.tools.json
|
import moe.fuqiuluo.shamrock.tools.json
|
||||||
import moe.fuqiuluo.shamrock.tools.jsonArray
|
import moe.fuqiuluo.shamrock.tools.jsonArray
|
||||||
import moe.fuqiuluo.symbols.OneBotHandler
|
import moe.fuqiuluo.symbols.OneBotHandler
|
||||||
import java.util.Timer
|
|
||||||
import kotlin.concurrent.timerTask
|
|
||||||
|
|
||||||
@OneBotHandler(".handle_quick_operation_async")
|
@OneBotHandler(".handle_quick_operation_async")
|
||||||
internal object QuickOperation : IActionHandler() {
|
internal object QuickOperation : IActionHandler() {
|
||||||
@ -87,9 +86,10 @@ internal object QuickOperation : IActionHandler() {
|
|||||||
if (MsgConstant.KCHATTYPEGROUP == record.chatType && operation["delete"].asBooleanOrNull == true) {
|
if (MsgConstant.KCHATTYPEGROUP == record.chatType && operation["delete"].asBooleanOrNull == true) {
|
||||||
val duration = operation["delay"].asIntOrNull
|
val duration = operation["delay"].asIntOrNull
|
||||||
if (duration != null) {
|
if (duration != null) {
|
||||||
Timer().schedule(timerTask {
|
GlobalScope.launch {
|
||||||
GlobalScope.launch { MsgSvc.recallMsg(msgHash) }
|
delay(duration.toLong())
|
||||||
}, duration.toLong())
|
MsgSvc.recallMsg(msgHash)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MsgSvc.recallMsg(msgHash)
|
MsgSvc.recallMsg(msgHash)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user