mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Support /set_group_comment_face
This commit is contained in:
parent
e07e75747a
commit
c97f79335a
@ -0,0 +1,14 @@
|
||||
package moe.whitechi73.protobuf.oidb.cmd0x9082
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
|
||||
@Serializable
|
||||
data class Oidb0x9082(
|
||||
@ProtoNumber(2) val peer: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(3) val msgSeq: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(4) val faceIndex: String = "",
|
||||
@ProtoNumber(5) val flag: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(6) val u1: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(7) val u2: UInt = UInt.MIN_VALUE,
|
||||
)
|
@ -0,0 +1,19 @@
|
||||
package moe.fuqiuluo.qqinterface.servlet
|
||||
|
||||
import kotlinx.serialization.encodeToByteArray
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import moe.whitechi73.protobuf.oidb.cmd0x9082.Oidb0x9082
|
||||
|
||||
internal object ChatSvc: BaseSvc() {
|
||||
fun setGroupMessageCommentFace(peer: Long, msgSeq: ULong, faceIndex: String, isSet: Boolean) {
|
||||
val serviceId = if (isSet) 1 else 2
|
||||
sendOidb("OidbSvcTrpcTcp.0x9082_$serviceId", 36994, serviceId, ProtoBuf.encodeToByteArray(Oidb0x9082(
|
||||
peer = peer.toULong(),
|
||||
msgSeq = msgSeq,
|
||||
faceIndex = faceIndex,
|
||||
flag = 1u,
|
||||
u1 = 0u,
|
||||
u2 = 0u
|
||||
)))
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.qqinterface.servlet.ChatSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("set_group_comment_face")
|
||||
internal object SetGroupCommentFace: IActionHandler() {
|
||||
override suspend fun internalHandle(session: ActionSession): String {
|
||||
val groupId = session.getLong("group_id")
|
||||
val msgId = session.getIntOrNull("msg_id") ?: session.getInt("message_id")
|
||||
val faceId = session.getInt("face_id")
|
||||
val isSet = session.getBooleanOrDefault("is_set", true)
|
||||
return invoke(groupId, msgId, faceId, isSet, session.echo)
|
||||
}
|
||||
|
||||
operator fun invoke(groupId: Long, msgHash: Int, faceIndex: Int, isSet: Boolean, echo: JsonElement = EmptyJsonString): String {
|
||||
val mapping = MessageHelper.getMsgMappingByHash(msgHash)
|
||||
?: return error("failed to locate message", echo = echo)
|
||||
ChatSvc.setGroupMessageCommentFace(groupId, mapping.msgSeq.toULong(), faceIndex.toString(), isSet)
|
||||
return ok("success", echo = echo)
|
||||
}
|
||||
|
||||
override val requiredParams: Array<String> = arrayOf("group_id", "face_id")
|
||||
}
|
@ -1,19 +1,30 @@
|
||||
package moe.fuqiuluo.shamrock.remote.api
|
||||
|
||||
import io.ktor.http.ContentType
|
||||
import moe.fuqiuluo.shamrock.helper.LogicException
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Routing
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionManager
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.*
|
||||
import moe.fuqiuluo.shamrock.tools.fetch
|
||||
import moe.fuqiuluo.shamrock.tools.fetchGetOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrThrow
|
||||
import moe.fuqiuluo.shamrock.tools.getOrPost
|
||||
|
||||
fun Routing.troopAction() {
|
||||
getOrPost("/set_group_comment_face") {
|
||||
val groupId = fetchOrThrow("group_id").toLong()
|
||||
val msgId = fetchOrNull("msg_id")?.toIntOrNull() ?: fetchOrThrow("message_id").toInt()
|
||||
val faceId = fetchOrThrow("face_id").toInt()
|
||||
val isSet = fetchGetOrNull("is_set") ?: "true"
|
||||
call.respondText(SetGroupCommentFace(groupId, msgId, faceId, when(isSet) {
|
||||
"true" -> true
|
||||
"false" -> false
|
||||
"1" -> true
|
||||
"0" -> false
|
||||
else -> true
|
||||
}), ContentType.Application.Json)
|
||||
}
|
||||
|
||||
getOrPost("/get_not_joined_group_info") {
|
||||
val groupId = fetchOrThrow("group_id")
|
||||
call.respondText(GetNotJoinedGroupInfo(groupId), ContentType.Application.Json)
|
||||
|
Loading…
x
Reference in New Issue
Block a user