mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-15 21:10:14 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
143e3e5491
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
开发版本. 频繁更新, 不保证高稳定性
|
开发版本. 频繁更新, 不保证高稳定性
|
||||||
|
|
||||||
|
### `0.8.1` *2019/12/15*
|
||||||
|
- 修复有时群资料无法获取的情况
|
||||||
|
- 现在 `At.qq`, `Long.qq` 等函数不再是 `suspend`
|
||||||
|
|
||||||
### `0.8.0` *2019/12/14*
|
### `0.8.0` *2019/12/14*
|
||||||
协议
|
协议
|
||||||
- 现在查询群资料时可处理群号无效的情况
|
- 现在查询群资料时可处理群号无效的情况
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# style guide
|
# style guide
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
# config
|
# config
|
||||||
mirai_version=0.8.0
|
mirai_version=0.8.1
|
||||||
kotlin.incremental.multiplatform=true
|
kotlin.incremental.multiplatform=true
|
||||||
kotlin.parallel.tasks.in.project=true
|
kotlin.parallel.tasks.in.project=true
|
||||||
# kotlin
|
# kotlin
|
||||||
|
@ -139,7 +139,7 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
|
|||||||
@MessageDsl
|
@MessageDsl
|
||||||
suspend inline fun always(noinline onEvent: @MessageDsl suspend T.(String) -> Unit) {
|
suspend inline fun always(noinline onEvent: @MessageDsl suspend T.(String) -> Unit) {
|
||||||
content({ true }, onEvent)
|
content({ true }, onEvent)
|
||||||
} // TODO: 2019/12/4 这些 onEvent 都应该为 crossinline, 而这会导致一个 CompilationException
|
} // TODO: 2019/12/4 这些 onEvent 都应该为 cross-inline, 而这会导致一个 CompilationException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果消息内容 `==` [equals], 就执行 [onEvent]
|
* 如果消息内容 `==` [equals], 就执行 [onEvent]
|
||||||
|
@ -17,7 +17,10 @@ import net.mamoe.mirai.network.protocol.tim.packet.PacketVersion
|
|||||||
import net.mamoe.mirai.network.protocol.tim.packet.action.ImageLink
|
import net.mamoe.mirai.network.protocol.tim.packet.action.ImageLink
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
import net.mamoe.mirai.utils.internal.coerceAtLeastOrFail
|
import net.mamoe.mirai.utils.internal.coerceAtLeastOrFail
|
||||||
import net.mamoe.mirai.utils.io.*
|
import net.mamoe.mirai.utils.io.printTLVMap
|
||||||
|
import net.mamoe.mirai.utils.io.read
|
||||||
|
import net.mamoe.mirai.utils.io.readTLVMap
|
||||||
|
import net.mamoe.mirai.utils.io.readUShortLVByteArray
|
||||||
import net.mamoe.mirai.withSession
|
import net.mamoe.mirai.withSession
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
@ -89,11 +92,11 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : EventPacket
|
|||||||
suspend inline fun Image.download(): ByteReadPacket = getLink().download()
|
suspend inline fun Image.download(): ByteReadPacket = getLink().download()
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
suspend inline fun At.qq(): QQ = bot.getQQ(this.target)
|
fun At.qq(): QQ = bot.getQQ(this.target)
|
||||||
|
|
||||||
suspend inline fun Int.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0).toUInt())
|
fun Int.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0).toUInt())
|
||||||
suspend inline fun Long.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0))
|
fun Long.qq(): QQ = bot.getQQ(this.coerceAtLeastOrFail(0))
|
||||||
suspend inline fun UInt.qq(): QQ = bot.getQQ(this)
|
fun UInt.qq(): QQ = bot.getQQ(this)
|
||||||
|
|
||||||
suspend inline fun Int.group(): Group = bot.getGroup(this.coerceAtLeastOrFail(0).toUInt())
|
suspend inline fun Int.group(): Group = bot.getGroup(this.coerceAtLeastOrFail(0).toUInt())
|
||||||
suspend inline fun Long.group(): Group = bot.getGroup(this.coerceAtLeastOrFail(0))
|
suspend inline fun Long.group(): Group = bot.getGroup(this.coerceAtLeastOrFail(0))
|
||||||
@ -140,42 +143,42 @@ internal object GroupMessageEventParserAndHandler : KnownEventParserAndHandler<G
|
|||||||
readUShortLVByteArray()
|
readUShortLVByteArray()
|
||||||
discardExact(2)//2个0x00
|
discardExact(2)//2个0x00
|
||||||
|
|
||||||
with(this.debugPrint("群消息")) {
|
//debugPrintIfFail {
|
||||||
val message = readMessageChain()
|
val message = readMessageChain()
|
||||||
|
|
||||||
var senderPermission: MemberPermission = MemberPermission.MEMBER
|
var senderPermission: MemberPermission = MemberPermission.MEMBER
|
||||||
var senderName = ""
|
var senderName = ""
|
||||||
val map = readTLVMap(true)
|
val map = readTLVMap(true)
|
||||||
if (map.containsKey(18u)) {
|
if (map.containsKey(18u)) {
|
||||||
map.getValue(18u).read {
|
map.getValue(18u).read {
|
||||||
val tlv = readTLVMap(true)
|
val tlv = readTLVMap(true)
|
||||||
senderPermission = when (tlv.takeIf { it.containsKey(0x04u) }?.get(0x04u)?.getOrNull(3)?.toUInt()) {
|
senderPermission = when (tlv.takeIf { it.containsKey(0x04u) }?.get(0x04u)?.getOrNull(3)?.toUInt()) {
|
||||||
null -> MemberPermission.MEMBER
|
null -> MemberPermission.MEMBER
|
||||||
0x08u -> MemberPermission.OWNER
|
0x08u -> MemberPermission.OWNER
|
||||||
0x10u -> MemberPermission.ADMINISTRATOR
|
0x10u -> MemberPermission.ADMINISTRATOR
|
||||||
else -> {
|
else -> {
|
||||||
tlv.printTLVMap("TLV(tag=18) Map")
|
tlv.printTLVMap("TLV(tag=18) Map")
|
||||||
MiraiLogger.warning("Could not determine member permission, default permission MEMBER is being used")
|
MiraiLogger.warning("Could not determine member permission, default permission MEMBER is being used")
|
||||||
MemberPermission.MEMBER
|
MemberPermission.MEMBER
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
senderName = when {
|
senderName = when {
|
||||||
tlv.containsKey(0x01u) -> String(tlv.getValue(0x01u))//这个人的qq昵称
|
tlv.containsKey(0x01u) -> String(tlv.getValue(0x01u))//这个人的qq昵称
|
||||||
tlv.containsKey(0x02u) -> String(tlv.getValue(0x02u))//这个人的群名片
|
tlv.containsKey(0x02u) -> String(tlv.getValue(0x02u))//这个人的群名片
|
||||||
else -> {
|
else -> {
|
||||||
tlv.printTLVMap("TLV(tag=18) Map")
|
tlv.printTLVMap("TLV(tag=18) Map")
|
||||||
MiraiLogger.warning("Could not determine senderName")
|
MiraiLogger.warning("Could not determine senderName")
|
||||||
"null"
|
"null"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val group = bot.getGroup(groupNumber)
|
|
||||||
return GroupMessage(group, senderName, senderPermission, group.getMember(qq), message).apply { this.botVar = bot }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val group = bot.getGroup(groupNumber)
|
||||||
|
return GroupMessage(group, senderName, senderPermission, group.getMember(qq), message).apply { this.botVar = bot }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,26 +2,8 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai
|
package net.mamoe.mirai
|
||||||
|
|
||||||
import kotlinx.io.core.buildPacket
|
|
||||||
import kotlinx.io.core.readBytes
|
|
||||||
import net.mamoe.mirai.contact.GroupInternalId
|
|
||||||
import net.mamoe.mirai.contact.toId
|
|
||||||
import net.mamoe.mirai.utils.io.toByteArray
|
|
||||||
import net.mamoe.mirai.utils.io.toUHexString
|
|
||||||
|
|
||||||
actual object MiraiEnvironment {
|
actual object MiraiEnvironment {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
actual val platform: Platform
|
actual val platform: Platform
|
||||||
get() = Platform.JVM
|
get() = Platform.JVM
|
||||||
}
|
|
||||||
|
|
||||||
@ExperimentalUnsignedTypes
|
|
||||||
fun main() {
|
|
||||||
println(GroupInternalId(2793514141u).toId().value.toLong())
|
|
||||||
println(GroupInternalId(2040208217u).toId().value.toLong())
|
|
||||||
println(289942298u.toByteArray().toUHexString())
|
|
||||||
println(1040400290u.toByteArray().toUHexString())
|
|
||||||
println(buildPacket {
|
|
||||||
writeStringUtf8("信用卡")
|
|
||||||
}.readBytes().toUByteArray().toUHexString())
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user