mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: fix #216
This commit is contained in:
parent
dd1b909bb0
commit
67f52b8df0
@ -0,0 +1,16 @@
|
|||||||
|
package moe.whitechi73.protobuf.oidb.cmd0xf16
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Oidb0xf16(
|
||||||
|
@ProtoNumber(1) var setGroupRemarkReq: SetGroupRemarkReq? = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetGroupRemarkReq(
|
||||||
|
@ProtoNumber(1) var groupCode: ULong,
|
||||||
|
@ProtoNumber(2) var groupUin: ULong,
|
||||||
|
@ProtoNumber(3) var groupRemark: String
|
||||||
|
)
|
@ -42,10 +42,12 @@ import kotlinx.coroutines.sync.Mutex
|
|||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.coroutines.withTimeoutOrNull
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
|
import kotlinx.serialization.encodeToByteArray
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
import kotlinx.serialization.json.decodeFromStream
|
import kotlinx.serialization.json.decodeFromStream
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import kotlinx.serialization.protobuf.ProtoBuf
|
||||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc.getLongUin
|
import moe.fuqiuluo.qqinterface.servlet.TicketSvc.getLongUin
|
||||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc.getUin
|
import moe.fuqiuluo.qqinterface.servlet.TicketSvc.getUin
|
||||||
import moe.fuqiuluo.qqinterface.servlet.structures.GroupAtAllRemainInfo
|
import moe.fuqiuluo.qqinterface.servlet.structures.GroupAtAllRemainInfo
|
||||||
@ -73,6 +75,8 @@ import moe.fuqiuluo.shamrock.utils.FileUtils
|
|||||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||||
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
import moe.fuqiuluo.shamrock.xposed.helper.AppRuntimeFetcher
|
||||||
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
||||||
|
import moe.whitechi73.protobuf.oidb.cmd0xf16.Oidb0xf16
|
||||||
|
import moe.whitechi73.protobuf.oidb.cmd0xf16.SetGroupRemarkReq
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
import tencent.im.group.group_member_info
|
import tencent.im.group.group_member_info
|
||||||
import tencent.im.oidb.cmd0x88d.oidb_0x88d
|
import tencent.im.oidb.cmd0x88d.oidb_0x88d
|
||||||
@ -267,6 +271,17 @@ internal object GroupSvc: BaseSvc() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun modifyGroupRemark(groupId: Long, remark: String): Boolean {
|
||||||
|
sendOidb("OidbSvc.0xf16_1", 3862, 1, ProtoBuf.encodeToByteArray(Oidb0xf16(
|
||||||
|
setGroupRemarkReq = SetGroupRemarkReq(
|
||||||
|
groupCode = groupId.toULong(),
|
||||||
|
groupUin = groupCode2GroupUin(groupId).toULong(),
|
||||||
|
groupRemark = remark
|
||||||
|
)
|
||||||
|
)))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setEssenceMessage(groupId: Long, seq: Long, rand: Long): Pair<Boolean, String> {
|
suspend fun setEssenceMessage(groupId: Long, seq: Long, rand: Long): Pair<Boolean, String> {
|
||||||
val buffer = sendOidbAW("OidbSvc.0xeac_1", 3756, 1, oidb_0xeac.ReqBody().apply {
|
val buffer = sendOidbAW("OidbSvc.0xeac_1", 3756, 1, oidb_0xeac.ReqBody().apply {
|
||||||
group_code.set(groupId)
|
group_code.set(groupId)
|
||||||
@ -452,6 +467,37 @@ internal object GroupSvc: BaseSvc() {
|
|||||||
return calc * 1000000L + groupuin % 1000000L
|
return calc * 1000000L + groupuin % 1000000L
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun groupCode2GroupUin(groupcode: Long): Long {
|
||||||
|
var calc = groupcode / 1000000L
|
||||||
|
loop@ while (true) calc += when (calc) {
|
||||||
|
in 0..10 -> {
|
||||||
|
(202 - 0).toLong()
|
||||||
|
}
|
||||||
|
in 11..19 -> {
|
||||||
|
(480 - 11).toLong()
|
||||||
|
}
|
||||||
|
in 20..66 -> {
|
||||||
|
(2100 - 20).toLong()
|
||||||
|
}
|
||||||
|
in 67..156 -> {
|
||||||
|
(2010 - 67).toLong()
|
||||||
|
}
|
||||||
|
in 157..209 -> {
|
||||||
|
(2147 - 157).toLong()
|
||||||
|
}
|
||||||
|
in 210..309 -> {
|
||||||
|
(4100 - 210).toLong()
|
||||||
|
}
|
||||||
|
in 310..499 -> {
|
||||||
|
(3800 - 310).toLong()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return calc * 1000000L + groupcode % 1000000L
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun getShareTroopArkMsg(groupId: Long): String {
|
suspend fun getShareTroopArkMsg(groupId: Long): String {
|
||||||
val reqBody = join_group_link.ReqBody()
|
val reqBody = join_group_link.ReqBody()
|
||||||
reqBody.get_ark.set(true)
|
reqBody.get_ark.set(true)
|
||||||
|
@ -34,7 +34,7 @@ internal object GetRecord: IActionHandler() {
|
|||||||
url = "/res/${audioFile.nameWithoutExtension}"
|
url = "/res/${audioFile.nameWithoutExtension}"
|
||||||
), echo)
|
), echo)
|
||||||
} else {
|
} else {
|
||||||
error("not found record file from cache")
|
error("not found record file from cache", echo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ internal object ModifyTroopMemberName: IActionHandler() {
|
|||||||
}
|
}
|
||||||
return if(GroupSvc.modifyGroupMemberCard(groupId.toLong(), userId.toLong(), card))
|
return if(GroupSvc.modifyGroupMemberCard(groupId.toLong(), userId.toLong(), card))
|
||||||
ok("成功", echo)
|
ok("成功", echo)
|
||||||
else error("check if member or group exist")
|
else error("check if member or group exist", echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val requiredParams: Array<String> = arrayOf("group_id", "user_id")
|
override val requiredParams: Array<String> = arrayOf("group_id", "user_id")
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||||
|
|
||||||
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
||||||
|
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_remark", ["modify_group_remark"])
|
||||||
|
internal object ModifyTroopRemark: IActionHandler() {
|
||||||
|
override suspend fun internalHandle(session: ActionSession): String {
|
||||||
|
val groupId = session.getString("group_id")
|
||||||
|
val remark = session.getStringOrNull("remark") ?: ""
|
||||||
|
return invoke(groupId, remark, session.echo)
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun invoke(groupId: String, remark: String, echo: JsonElement = EmptyJsonString): String {
|
||||||
|
return if(GroupSvc.modifyGroupRemark(groupId.toLong(), remark))
|
||||||
|
ok("成功", echo)
|
||||||
|
else error("check if member or group exist", echo)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val requiredParams: Array<String> = arrayOf("group_id")
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user