Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #268 from huankong233/master
Browse files Browse the repository at this point in the history
修正错误部分错误
  • Loading branch information
whitechi73 authored Feb 29, 2024
2 parents d614217 + 9546e90 commit 352aa5f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import moe.fuqiuluo.symbols.OneBotHandler
import moe.fuqiuluo.symbols.decodeProtobuf
import protobuf.fav.WeiyunComm

@OneBotHandler("fav.add_text_msg", ["fav.add_text_msg"])
@OneBotHandler("fav.add_text_msg", ["fav.add_text_message"])
internal object FavAddTextMsg: IActionHandler() {
override suspend fun internalHandle(session: ActionSession): String {
val uin = session.getLong("user_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal object QuickOperation : IActionHandler() {
}


return logic("操作成功", session.echo)
return ok("操作成功", session.echo)
}

override val requiredParams: Array<String> = arrayOf("context", "operation", "self_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import moe.fuqiuluo.shamrock.remote.action.ActionSession
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
import moe.fuqiuluo.symbols.OneBotHandler

@OneBotHandler("sanc_qrcode")
@OneBotHandler("scan_qrcode")
internal object ScanQRCode: IActionHandler() {
override suspend fun internalHandle(session: ActionSession): String {
val qrcode = QRoute.api(IQRCodeApi::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package moe.fuqiuluo.shamrock.remote.action.handlers

import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
import moe.fuqiuluo.shamrock.helper.ParamsException
import moe.fuqiuluo.shamrock.remote.action.ActionSession
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
import moe.fuqiuluo.shamrock.tools.jsonArray
Expand All @@ -9,19 +10,25 @@ import moe.fuqiuluo.symbols.OneBotHandler
@OneBotHandler("send_group_message", ["send_group_msg"])
internal object SendGroupMessage: IActionHandler() {
override suspend fun internalHandle(session: ActionSession): String {
val groupId = session.getLong("group_id")
val retryCnt = session.getIntOrNull("retry_cnt")
val recallDuration = session.getLongOrNull("recall_duration")
return if (session.isString("message")) {
val autoEscape = session.getBooleanOrDefault("auto_escape", false)
val message = session.getString("message")
SendMessage(MsgConstant.KCHATTYPEGROUP, groupId.toString(), message, autoEscape, echo = session.echo, retryCnt = retryCnt ?: 5, recallDuration = recallDuration)
} else if (session.isObject("message")) {
val message = session.getObject("message")
SendMessage(MsgConstant.KCHATTYPEGROUP, groupId.toString(), listOf( message ).jsonArray, session.echo, retryCnt = retryCnt ?: 5, recallDuration = recallDuration)
} else {
val message = session.getArray("message")
SendMessage(MsgConstant.KCHATTYPEGROUP, groupId.toString(), message, session.echo, retryCnt = retryCnt ?: 5, recallDuration = recallDuration)
try{
val groupId = session.getLong("group_id")
val retryCnt = session.getIntOrNull("retry_cnt")
val recallDuration = session.getLongOrNull("recall_duration")
return if (session.isString("message")) {
val autoEscape = session.getBooleanOrDefault("auto_escape", false)
val message = session.getString("message")
SendMessage(MsgConstant.KCHATTYPEGROUP, groupId.toString(), message, autoEscape, echo = session.echo, retryCnt = retryCnt ?: 5, recallDuration = recallDuration)
} else if (session.isObject("message")) {
val message = session.getObject("message")
SendMessage(MsgConstant.KCHATTYPEGROUP, groupId.toString(), listOf( message ).jsonArray, session.echo, retryCnt = retryCnt ?: 5, recallDuration = recallDuration)
} else {
val message = session.getArray("message")
SendMessage(MsgConstant.KCHATTYPEGROUP, groupId.toString(), message, session.echo, retryCnt = retryCnt ?: 5, recallDuration = recallDuration)
}
} catch (e: ParamsException) {
return noParam(e.message!!, session.echo)
} catch (e: Throwable) {
return logic(e.message ?: e.toString(), session.echo)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package moe.fuqiuluo.shamrock.remote.action.handlers

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
import moe.fuqiuluo.qqinterface.servlet.structures.GuildInfo
import moe.fuqiuluo.shamrock.remote.action.ActionSession
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
Expand All @@ -17,11 +20,16 @@ internal object SendGroupSign: IActionHandler() {
suspend operator fun invoke(groupId: Long, echo: JsonElement = EmptyJsonString): String {
val ret = GroupSvc.groupSign(groupId)
return if (ret.isSuccess) {
ok(ret.getOrNull() ?: "", echo)
ok(Message(message = ret.getOrNull() ?: ""), echo, "成功")
} else {
logic(ret.exceptionOrNull()?.message ?: "", echo)
}
}

override val requiredParams: Array<String> = arrayOf("group_id")

@Serializable
data class Message(
@SerialName("message") var message: String = ""
)
}

0 comments on commit 352aa5f

Please sign in to comment.