Move AddFriend to another file, 0.1.5

This commit is contained in:
Him188 2019-11-23 23:09:58 +08:00
parent 1d17876f5e
commit ae37546dd5
8 changed files with 164 additions and 167 deletions

View File

@ -1,7 +1,7 @@
# style guide # style guide
kotlin.code.style=official kotlin.code.style=official
# config # config
mirai_version=0.1.4 mirai_version=0.1.5
kotlin.incremental.multiplatform=true kotlin.incremental.multiplatform=true
kotlin.parallel.tasks.in.project=true kotlin.parallel.tasks.in.project=true
# kotlin # kotlin

View File

@ -52,8 +52,8 @@ fun Application.mirai() {
mirai("/addFriend") { mirai("/addFriend") {
Bot.instanceWhose(qq = param("bot")).addFriend( Bot.instanceWhose(qq = param("bot")).addFriend(
id = param("qq"), id = param("qq"),
lazyMessage = paramOrNull<String?>("message")?.let { { it } } ?: { "" }, message = paramOrNull<String?>("message")?.let { it },
lazyRemark = paramOrNull<String?>("remark")?.let { { it } } ?: { "" } remark = paramOrNull<String?>("remark")?.let { it }
) )
call.ok() call.ok()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -100,12 +100,7 @@ suspend inline fun Bot.alsoLogin(lazyMessageWhenLoginFailed: (LoginResult) -> St
*/ */
@UseExperimental(ExperimentalContracts::class) @UseExperimental(ExperimentalContracts::class)
@JvmOverloads @JvmOverloads
suspend inline fun Bot.addFriend(id: UInt, lazyMessage: () -> String = { "" }, noinline lazyRemark: () -> String = { "" }): AddFriendResult { suspend inline fun Bot.addFriend(id: UInt, message: String? = null, remark: String? = null): AddFriendResult = contacts.addFriend(id, message, remark)
contract {
callsInPlace(lazyMessage, InvocationKind.AT_MOST_ONCE)
}
return this.contacts.addFriend(id, lazyMessage, lazyRemark)
}
/** /**
* 取得机器人的 QQ * 取得机器人的 QQ

View File

@ -39,10 +39,6 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d
*/ */
open val id: PacketId by lazy { annotatedId.id } open val id: PacketId by lazy { annotatedId.id }
init {
@Suppress("LeakingThis")
}
/** /**
* **解码**服务器的回复数据包 * **解码**服务器的回复数据包
*/ */

View File

@ -206,11 +206,11 @@ object AddFriendPacket : SessionPacketFactory<AddFriendPacket.Response>() {
/** /**
* 验证消息 * 验证消息
*/ */
message: String, message: String?,
/** /**
* 备注名 * 备注名
*/ */
remark: String, //// TODO: 2019/11/15 无备注的情况 remark: String?, //// TODO: 2019/11/15 无备注的情况
key: FriendAdditionKey key: FriendAdditionKey
): OutgoingPacket = buildSessionPacket(bot, sessionKey) { ): OutgoingPacket = buildSessionPacket(bot, sessionKey) {
@ -235,13 +235,13 @@ object AddFriendPacket : SessionPacketFactory<AddFriendPacket.Response>() {
writeQQ(qq) writeQQ(qq)
writeByte(0) writeByte(0)
writeByte(0); writeShort(key.value.readRemaining.toShort()); writeFully(key.value) writeByte(0); writeShort(key.value.readRemaining.toShort()); writeFully(key.value)
writeByte(1); writeShortLVString(message) writeByte(1); writeShortLVString(message ?: "")
writeShortLVPacket { writeShortLVPacket {
//00 01 00 01 00 00 00 1B E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A 00 05 00 00 00 00 01 //00 01 00 01 00 00 00 1B E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A E5 95 8A 00 05 00 00 00 00 01
//00 01 00 01 00 00 00 00 00 05 00 00 00 00 01 //00 01 00 01 00 00 00 00 00 05 00 00 00 00 01
writeHex("00 01 00 01 00 00")// TODO: 2019/11/11 这里面或者下面那个hex可能包含分组信息. 这两次测试都是用的默认分组即我的好友 writeHex("00 01 00 01 00 00")// TODO: 2019/11/11 这里面或者下面那个hex可能包含分组信息. 这两次测试都是用的默认分组即我的好友
writeShortLVString(remark) writeShortLVString(remark ?: "")
writeHex("00 05 00 00 00 00 01") writeHex("00 05 00 00 00 00 01")
} }
writeByte(0) writeByte(0)

View File

@ -0,0 +1,6 @@
package net.mamoe.mirai.network.protocol.tim.packet.action
class MemberKickEvent
//object MemberKickEventPacketFactory : SessionPacketFactory<