mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-17 15:05:47 +08:00
Move AddFriend to another file, 0.1.5
This commit is contained in:
parent
1d17876f5e
commit
ae37546dd5
@ -1,7 +1,7 @@
|
||||
# style guide
|
||||
kotlin.code.style=official
|
||||
# config
|
||||
mirai_version=0.1.4
|
||||
mirai_version=0.1.5
|
||||
kotlin.incremental.multiplatform=true
|
||||
kotlin.parallel.tasks.in.project=true
|
||||
# kotlin
|
||||
|
@ -52,8 +52,8 @@ fun Application.mirai() {
|
||||
mirai("/addFriend") {
|
||||
Bot.instanceWhose(qq = param("bot")).addFriend(
|
||||
id = param("qq"),
|
||||
lazyMessage = paramOrNull<String?>("message")?.let { { it } } ?: { "" },
|
||||
lazyRemark = paramOrNull<String?>("remark")?.let { { it } } ?: { "" }
|
||||
message = paramOrNull<String?>("message")?.let { it },
|
||||
remark = paramOrNull<String?>("remark")?.let { it }
|
||||
)
|
||||
|
||||
call.ok()
|
||||
|
File diff suppressed because one or more lines are too long
149
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAddFriend.kt
Normal file
149
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAddFriend.kt
Normal file
File diff suppressed because one or more lines are too long
@ -100,12 +100,7 @@ suspend inline fun Bot.alsoLogin(lazyMessageWhenLoginFailed: (LoginResult) -> St
|
||||
*/
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
@JvmOverloads
|
||||
suspend inline fun Bot.addFriend(id: UInt, lazyMessage: () -> String = { "" }, noinline lazyRemark: () -> String = { "" }): AddFriendResult {
|
||||
contract {
|
||||
callsInPlace(lazyMessage, InvocationKind.AT_MOST_ONCE)
|
||||
}
|
||||
return this.contacts.addFriend(id, lazyMessage, lazyRemark)
|
||||
}
|
||||
suspend inline fun Bot.addFriend(id: UInt, message: String? = null, remark: String? = null): AddFriendResult = contacts.addFriend(id, message, remark)
|
||||
|
||||
/**
|
||||
* 取得机器人的 QQ 号
|
||||
|
@ -39,10 +39,6 @@ abstract class PacketFactory<out TPacket : Packet, TDecrypter : Decrypter>(val d
|
||||
*/
|
||||
open val id: PacketId by lazy { annotatedId.id }
|
||||
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
}
|
||||
|
||||
/**
|
||||
* **解码**服务器的回复数据包
|
||||
*/
|
||||
|
@ -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
|
||||
): OutgoingPacket = buildSessionPacket(bot, sessionKey) {
|
||||
|
||||
@ -235,13 +235,13 @@ object AddFriendPacket : SessionPacketFactory<AddFriendPacket.Response>() {
|
||||
writeQQ(qq)
|
||||
writeByte(0)
|
||||
writeByte(0); writeShort(key.value.readRemaining.toShort()); writeFully(key.value)
|
||||
writeByte(1); writeShortLVString(message)
|
||||
writeByte(1); writeShortLVString(message ?: "")
|
||||
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 00 00 05 00 00 00 00 01
|
||||
writeHex("00 01 00 01 00 00")// TODO: 2019/11/11 这里面或者下面那个hex可能包含分组信息. 这两次测试都是用的默认分组即我的好友
|
||||
writeShortLVString(remark)
|
||||
writeShortLVString(remark ?: "")
|
||||
writeHex("00 05 00 00 00 00 01")
|
||||
}
|
||||
writeByte(0)
|
||||
|
@ -0,0 +1,6 @@
|
||||
package net.mamoe.mirai.network.protocol.tim.packet.action
|
||||
|
||||
|
||||
class MemberKickEvent
|
||||
|
||||
//object MemberKickEventPacketFactory : SessionPacketFactory<
|
Loading…
Reference in New Issue
Block a user