mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-12 14:00:12 +08:00
Fix At
This commit is contained in:
parent
4f6691acc6
commit
e580992e0b
@ -28,12 +28,13 @@ internal fun At.toJceData(): ImMsgBody.Text {
|
|||||||
return ImMsgBody.Text(
|
return ImMsgBody.Text(
|
||||||
str = text,
|
str = text,
|
||||||
attr6Buf = buildPacket {
|
attr6Buf = buildPacket {
|
||||||
writeShort(1)
|
// MessageForText$AtTroopMemberInfo
|
||||||
writeShort(0)
|
writeShort(1) // const
|
||||||
writeShort(text.length.toShort())
|
writeShort(0) // startPos
|
||||||
writeByte(1)
|
writeShort(text.length.toShort()) // textLen
|
||||||
writeInt(target.toInt())
|
writeByte(0) // flag, may=1
|
||||||
writeShort(0)
|
writeInt(target.toInt()) // uin
|
||||||
|
writeShort(0) // const
|
||||||
}.readBytes()
|
}.readBytes()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -207,7 +208,15 @@ notOnlineImage=NotOnlineImage#2050019814 {
|
|||||||
private val atAllData = ImMsgBody.Elem(
|
private val atAllData = ImMsgBody.Elem(
|
||||||
text = ImMsgBody.Text(
|
text = ImMsgBody.Text(
|
||||||
str = "@全体成员",
|
str = "@全体成员",
|
||||||
attr6Buf = "00 01 00 00 00 05 01 00 00 00 00 00 00".hexToBytes()
|
attr6Buf = buildPacket {
|
||||||
|
// MessageForText$AtTroopMemberInfo
|
||||||
|
writeShort(1) // const
|
||||||
|
writeShort(0) // startPos
|
||||||
|
writeShort("@全体成员".length.toShort()) // textLen
|
||||||
|
writeByte(1) // flag, may=1
|
||||||
|
writeInt(0) // uin
|
||||||
|
writeShort(0) // const
|
||||||
|
}.readBytes()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -225,7 +234,7 @@ internal fun MessageChain.toRichTextElems(): MutableList<ImMsgBody.Elem> {
|
|||||||
this.forEach {
|
this.forEach {
|
||||||
when (it) {
|
when (it) {
|
||||||
is PlainText -> elements.add(ImMsgBody.Elem(text = ImMsgBody.Text(str = it.stringValue)))
|
is PlainText -> elements.add(ImMsgBody.Elem(text = ImMsgBody.Text(str = it.stringValue)))
|
||||||
is At -> elements.add(ImMsgBody.Elem(text = it.toJceData()))
|
is At -> elements.add(ImMsgBody.Elem(text = it.toJceData())).also { elements.add(ImMsgBody.Elem(text = ImMsgBody.Text(str = " "))) }
|
||||||
is CustomFaceFromFile -> elements.add(ImMsgBody.Elem(customFace = it.toJceData()))
|
is CustomFaceFromFile -> elements.add(ImMsgBody.Elem(customFace = it.toJceData()))
|
||||||
is CustomFaceFromServer -> elements.add(ImMsgBody.Elem(customFace = it.delegate))
|
is CustomFaceFromServer -> elements.add(ImMsgBody.Elem(customFace = it.delegate))
|
||||||
is NotOnlineImageFromServer -> elements.add(ImMsgBody.Elem(notOnlineImage = it.delegate))
|
is NotOnlineImageFromServer -> elements.add(ImMsgBody.Elem(notOnlineImage = it.delegate))
|
||||||
|
@ -263,6 +263,9 @@ internal class MessageSvc {
|
|||||||
override fun toString(): String = "MessageSvc.PbSendMsg.Response.SUCCESS"
|
override fun toString(): String = "MessageSvc.PbSendMsg.Response.SUCCESS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 121: 被限制? 个别号才不能发
|
||||||
|
*/
|
||||||
data class Failed(val resultType: Int, val errorCode: Int, val errorMessage: String) : Response() {
|
data class Failed(val resultType: Int, val errorCode: Int, val errorMessage: String) : Response() {
|
||||||
override fun toString(): String =
|
override fun toString(): String =
|
||||||
"MessageSvc.PbSendMsg.Response.Failed(resultType=$resultType, errorCode=$errorCode, errorMessage=$errorMessage)"
|
"MessageSvc.PbSendMsg.Response.Failed(resultType=$resultType, errorCode=$errorCode, errorMessage=$errorMessage)"
|
||||||
@ -352,13 +355,12 @@ internal class MessageSvc {
|
|||||||
): OutgoingPacket = buildOutgoingUniPacket(client) {
|
): OutgoingPacket = buildOutgoingUniPacket(client) {
|
||||||
|
|
||||||
val source = MessageSourceFromSend(
|
val source = MessageSourceFromSend(
|
||||||
messageUid = Random.nextInt().absoluteValue.toLong() and 0xffffffff,
|
messageUid = Random.nextInt().absoluteValue.toLong(),
|
||||||
senderId = client.uin,
|
senderId = client.uin,
|
||||||
time = currentTimeSeconds + client.timeDifference,
|
time = currentTimeSeconds + client.timeDifference,
|
||||||
groupId = groupCode,
|
groupId = groupCode,
|
||||||
sourceMessage = message
|
sourceMessage = message
|
||||||
)
|
)
|
||||||
message.addOrRemove(source)
|
|
||||||
|
|
||||||
///writeFully("0A 08 0A 06 08 89 FC A6 8C 0B 12 06 08 01 10 00 18 00 1A 1F 0A 1D 12 08 0A 06 0A 04 F0 9F 92 A9 12 11 AA 02 0E 88 01 00 9A 01 08 78 00 F8 01 00 C8 02 00 20 9B 7A 28 F4 CA 9B B8 03 32 34 08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00 40 01".hexToBytes())
|
///writeFully("0A 08 0A 06 08 89 FC A6 8C 0B 12 06 08 01 10 00 18 00 1A 1F 0A 1D 12 08 0A 06 0A 04 F0 9F 92 A9 12 11 AA 02 0E 88 01 00 9A 01 08 78 00 F8 01 00 C8 02 00 20 9B 7A 28 F4 CA 9B B8 03 32 34 08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00 40 01".hexToBytes())
|
||||||
|
|
||||||
@ -380,6 +382,8 @@ internal class MessageSvc {
|
|||||||
msgVia = 1
|
msgVia = 1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message.addOrRemove(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
||||||
|
@ -112,9 +112,9 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact>(_bot: Bot) :
|
|||||||
/**
|
/**
|
||||||
* 创建 @ 这个账号的消息. 当且仅当消息为群消息时可用. 否则将会抛出 [IllegalArgumentException]
|
* 创建 @ 这个账号的消息. 当且仅当消息为群消息时可用. 否则将会抛出 [IllegalArgumentException]
|
||||||
*/
|
*/
|
||||||
inline fun QQ.at(): At = At(this as? Member ?: error("`QQ.at` can only be used in GroupMessage"))
|
fun QQ.at(): At = At(this as? Member ?: error("`QQ.at` can only be used in GroupMessage"))
|
||||||
|
|
||||||
inline fun At.member(): Member = (this@MessagePacketBase as? GroupMessage)?.group?.get(this.target) ?: error("`At.member` can only be used in GroupMessage")
|
fun At.member(): Member = (this@MessagePacketBase as? GroupMessage)?.group?.get(this.target) ?: error("`At.member` can only be used in GroupMessage")
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
@ -16,7 +16,9 @@ import kotlin.jvm.JvmMultifileClass
|
|||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "@全体成员"
|
* "@全体成员".
|
||||||
|
*
|
||||||
|
* 非会员每天只能发送 10 次 [AtAll]. 超出部分会被以普通文字看待.
|
||||||
*
|
*
|
||||||
* @see At at 单个群成员
|
* @see At at 单个群成员
|
||||||
*/
|
*/
|
||||||
@ -26,7 +28,7 @@ object AtAll : Message, Message.Key<AtAll> {
|
|||||||
// 自动为消息补充 " "
|
// 自动为消息补充 " "
|
||||||
|
|
||||||
override fun followedBy(tail: Message): MessageChain {
|
override fun followedBy(tail: Message): MessageChain {
|
||||||
if(tail is PlainText && tail.stringValue.startsWith(' ')){
|
if (tail is PlainText && tail.stringValue.startsWith(' ')) {
|
||||||
return super.followedBy(tail)
|
return super.followedBy(tail)
|
||||||
}
|
}
|
||||||
return super.followedBy(PlainText(" ")) + tail
|
return super.followedBy(PlainText(" ")) + tail
|
||||||
|
Loading…
Reference in New Issue
Block a user