Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
6480e78b
Commit
6480e78b
authored
Apr 08, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle ContactList syncing on new friend or member event.
parent
da39cc41
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
64 deletions
+149
-64
buildSrc/src/main/kotlin/Versions.kt
buildSrc/src/main/kotlin/Versions.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
...n/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
+41
-7
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt
...irai/qqandroid/network/protocol/packet/chat/NewContact.kt
+15
-15
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt
+7
-7
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+7
-7
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
...mmonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
+71
-20
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
+7
-7
No files found.
buildSrc/src/main/kotlin/Versions.kt
View file @
6480e78b
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
object
Versions
{
object
Versions
{
object
Mirai
{
object
Mirai
{
const
val
version
=
"0.3
4
.0"
const
val
version
=
"0.3
5
.0"
}
}
object
Kotlin
{
object
Kotlin
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
View file @
6480e78b
...
@@ -31,9 +31,9 @@ import net.mamoe.mirai.LowLevelAPI
...
@@ -31,9 +31,9 @@ import net.mamoe.mirai.LowLevelAPI
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.*
import
net.mamoe.mirai.data.*
import
net.mamoe.mirai.event.broadcast
import
net.mamoe.mirai.event.broadcast
import
net.mamoe.mirai.event.events.MemberJoinRequestEvent
import
net.mamoe.mirai.event.events.MessageRecallEvent
import
net.mamoe.mirai.event.events.MessageRecallEvent
import
net.mamoe.mirai.event.events.NewFriendEvent
import
net.mamoe.mirai.event.events.NewFriendRequestEvent
import
net.mamoe.mirai.event.events.NewGroupEvent
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.qqandroid.contact.MemberInfoImpl
import
net.mamoe.mirai.qqandroid.contact.MemberInfoImpl
...
@@ -70,6 +70,7 @@ internal fun Bot.asQQAndroidBot(): QQAndroidBot {
...
@@ -70,6 +70,7 @@ internal fun Bot.asQQAndroidBot(): QQAndroidBot {
return
this
as
QQAndroidBot
return
this
as
QQAndroidBot
}
}
@Suppress
(
"INVISIBLE_MEMBER"
)
@OptIn
(
MiraiInternalAPI
::
class
)
@OptIn
(
MiraiInternalAPI
::
class
)
internal
class
QQAndroidBot
constructor
(
internal
class
QQAndroidBot
constructor
(
context
:
Context
,
context
:
Context
,
...
@@ -77,7 +78,11 @@ internal class QQAndroidBot constructor(
...
@@ -77,7 +78,11 @@ internal class QQAndroidBot constructor(
configuration
:
BotConfiguration
configuration
:
BotConfiguration
)
:
QQAndroidBotBase
(
context
,
account
,
configuration
)
{
)
:
QQAndroidBotBase
(
context
,
account
,
configuration
)
{
override
suspend
fun
acceptNewFriend
(
event
:
NewFriendEvent
)
{
override
suspend
fun
acceptNewFriendRequest
(
event
:
NewFriendRequestEvent
)
{
check
(
event
.
responded
.
compareAndSet
(
expect
=
false
,
update
=
true
))
{
"the request $this has already been responded"
}
network
.
run
{
network
.
run
{
NewContact
.
SystemMsgNewFriend
.
Action
(
NewContact
.
SystemMsgNewFriend
.
Action
(
bot
.
client
,
bot
.
client
,
...
@@ -87,7 +92,11 @@ internal class QQAndroidBot constructor(
...
@@ -87,7 +92,11 @@ internal class QQAndroidBot constructor(
}
}
}
}
override
suspend
fun
rejectNewFriend
(
event
:
NewFriendEvent
,
blackList
:
Boolean
)
{
override
suspend
fun
rejectNewFriendRequest
(
event
:
NewFriendRequestEvent
,
blackList
:
Boolean
)
{
check
(
event
.
responded
.
compareAndSet
(
expect
=
false
,
update
=
true
))
{
"the request $this has already been responded"
}
network
.
run
{
network
.
run
{
NewContact
.
SystemMsgNewFriend
.
Action
(
NewContact
.
SystemMsgNewFriend
.
Action
(
bot
.
client
,
bot
.
client
,
...
@@ -98,17 +107,30 @@ internal class QQAndroidBot constructor(
...
@@ -98,17 +107,30 @@ internal class QQAndroidBot constructor(
}
}
}
}
override
suspend
fun
acceptNewGroup
(
event
:
NewGroupEvent
)
{
@OptIn
(
LowLevelAPI
::
class
)
override
suspend
fun
acceptMemberJoinRequest
(
event
:
MemberJoinRequestEvent
)
{
check
(
event
.
responded
.
compareAndSet
(
expect
=
false
,
update
=
true
))
{
"the request $this has already been responded"
}
network
.
run
{
network
.
run
{
NewContact
.
SystemMsgNewGroup
.
Action
(
NewContact
.
SystemMsgNewGroup
.
Action
(
bot
.
client
,
bot
.
client
,
event
,
event
,
accept
=
true
accept
=
true
).
sendWithoutExpect
()
).
sendWithoutExpect
()
bot
.
friends
.
delegate
.
addLast
(
bot
.
_lowLevelNewQQ
(
object
:
FriendInfo
{
override
val
uin
:
Long
get
()
=
event
.
fromId
override
val
nick
:
String
get
()
=
event
.
fromNick
}))
}
}
}
}
override
suspend
fun
rejectNewGroup
(
event
:
NewGroupEvent
,
blackList
:
Boolean
)
{
@OptIn
(
LowLevelAPI
::
class
)
override
suspend
fun
rejectMemberJoinRequest
(
event
:
MemberJoinRequestEvent
,
blackList
:
Boolean
)
{
check
(
event
.
responded
.
compareAndSet
(
expect
=
false
,
update
=
true
))
{
"the request $this has already been responded"
}
network
.
run
{
network
.
run
{
NewContact
.
SystemMsgNewGroup
.
Action
(
NewContact
.
SystemMsgNewGroup
.
Action
(
bot
.
client
,
bot
.
client
,
...
@@ -116,10 +138,22 @@ internal class QQAndroidBot constructor(
...
@@ -116,10 +138,22 @@ internal class QQAndroidBot constructor(
accept
=
false
,
accept
=
false
,
blackList
=
blackList
blackList
=
blackList
).
sendWithoutExpect
()
).
sendWithoutExpect
()
event
.
group
.
members
.
delegate
.
addLast
(
event
.
group
.
newMember
(
object
:
MemberInfo
{
override
val
nameCard
:
String
get
()
=
""
override
val
permission
:
MemberPermission
get
()
=
MemberPermission
.
MEMBER
override
val
specialTitle
:
String
get
()
=
""
override
val
muteTimestamp
:
Int
get
()
=
0
override
val
uin
:
Long
get
()
=
event
.
fromId
override
val
nick
:
String
get
()
=
event
.
fromNick
}))
}
}
}
}
override
suspend
fun
ignoreNewGroup
(
event
:
NewGroupEvent
,
blackList
:
Boolean
)
{
override
suspend
fun
ignoreMemberJoinRequest
(
event
:
MemberJoinRequestEvent
,
blackList
:
Boolean
)
{
check
(
event
.
responded
.
compareAndSet
(
expect
=
false
,
update
=
true
))
{
"the request $this has already been responded"
}
network
.
run
{
network
.
run
{
NewContact
.
SystemMsgNewGroup
.
Action
(
NewContact
.
SystemMsgNewGroup
.
Action
(
bot
.
client
,
bot
.
client
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt
View file @
6480e78b
...
@@ -2,8 +2,8 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat
...
@@ -2,8 +2,8 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.readBytes
import
kotlinx.io.core.readBytes
import
net.mamoe.mirai.event.events.
NewFriend
Event
import
net.mamoe.mirai.event.events.
MemberJoinRequest
Event
import
net.mamoe.mirai.event.events.New
Group
Event
import
net.mamoe.mirai.event.events.New
FriendRequest
Event
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgComm
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgComm
...
@@ -17,7 +17,7 @@ import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
...
@@ -17,7 +17,7 @@ import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
internal
class
NewContact
{
internal
class
NewContact
{
internal
object
SystemMsgNewFriend
:
internal
object
SystemMsgNewFriend
:
OutgoingPacketFactory
<
NewFriendEvent
?
>(
"ProfileService.Pb.ReqSystemMsgNew.Friend"
)
{
OutgoingPacketFactory
<
NewFriend
Request
Event
?
>(
"ProfileService.Pb.ReqSystemMsgNew.Friend"
)
{
operator
fun
invoke
(
client
:
QQAndroidClient
)
=
buildOutgoingUniPacket
(
client
)
{
operator
fun
invoke
(
client
:
QQAndroidClient
)
=
buildOutgoingUniPacket
(
client
)
{
writeProtoBuf
(
writeProtoBuf
(
...
@@ -41,17 +41,17 @@ internal class NewContact {
...
@@ -41,17 +41,17 @@ internal class NewContact {
}
}
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
NewFriendEvent
?
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
NewFriend
Request
Event
?
{
readBytes
().
loadAs
(
Structmsg
.
RspSystemMsgNew
.
serializer
()).
run
{
readBytes
().
loadAs
(
Structmsg
.
RspSystemMsgNew
.
serializer
()).
run
{
val
struct
=
friendmsgs
?.
firstOrNull
()
val
struct
=
friendmsgs
?.
firstOrNull
()
return
if
(
struct
==
null
)
null
else
{
return
if
(
struct
==
null
)
null
else
{
struct
.
msg
?.
run
{
struct
.
msg
?.
run
{
NewFriendEvent
(
NewFriend
Request
Event
(
bot
,
bot
,
struct
.
msgSeq
,
struct
.
msgSeq
,
msgAdditional
,
msgAdditional
,
struct
.
reqUin
,
struct
.
reqUin
,
group
Nam
e
,
group
Cod
e
,
reqUinNick
reqUinNick
)
)
}
}
...
@@ -63,7 +63,7 @@ internal class NewContact {
...
@@ -63,7 +63,7 @@ internal class NewContact {
operator
fun
invoke
(
operator
fun
invoke
(
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
event
:
NewFriendEvent
,
event
:
NewFriend
Request
Event
,
accept
:
Boolean
,
accept
:
Boolean
,
blackList
:
Boolean
=
false
blackList
:
Boolean
=
false
)
=
)
=
...
@@ -78,8 +78,8 @@ internal class NewContact {
...
@@ -78,8 +78,8 @@ internal class NewContact {
remark
=
""
,
remark
=
""
,
blacklist
=
!
accept
&&
blackList
blacklist
=
!
accept
&&
blackList
),
),
msgSeq
=
event
.
seq
,
msgSeq
=
event
.
eventId
,
reqUin
=
event
.
i
d
,
reqUin
=
event
.
fromI
d
,
srcId
=
6
,
srcId
=
6
,
subSrcId
=
7
,
subSrcId
=
7
,
subType
=
1
subType
=
1
...
@@ -93,7 +93,7 @@ internal class NewContact {
...
@@ -93,7 +93,7 @@ internal class NewContact {
internal
object
SystemMsgNewGroup
:
internal
object
SystemMsgNewGroup
:
OutgoingPacketFactory
<
NewGroup
Event
?
>(
"ProfileService.Pb.ReqSystemMsgNew.Group"
)
{
OutgoingPacketFactory
<
MemberJoinRequest
Event
?
>(
"ProfileService.Pb.ReqSystemMsgNew.Group"
)
{
operator
fun
invoke
(
client
:
QQAndroidClient
)
=
buildOutgoingUniPacket
(
client
)
{
operator
fun
invoke
(
client
:
QQAndroidClient
)
=
buildOutgoingUniPacket
(
client
)
{
writeProtoBuf
(
writeProtoBuf
(
...
@@ -129,13 +129,13 @@ internal class NewContact {
...
@@ -129,13 +129,13 @@ internal class NewContact {
}
}
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
NewGroup
Event
?
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
MemberJoinRequest
Event
?
{
readBytes
().
loadAs
(
Structmsg
.
RspSystemMsgNew
.
serializer
()).
run
{
readBytes
().
loadAs
(
Structmsg
.
RspSystemMsgNew
.
serializer
()).
run
{
val
struct
=
groupmsgs
?.
firstOrNull
()
val
struct
=
groupmsgs
?.
firstOrNull
()
return
if
(
struct
==
null
)
null
else
{
return
if
(
struct
==
null
)
null
else
{
struct
.
msg
?.
run
{
struct
.
msg
?.
run
{
NewGroup
Event
(
MemberJoinRequest
Event
(
bot
,
bot
,
struct
.
msgSeq
,
struct
.
msgSeq
,
msgAdditional
,
msgAdditional
,
...
@@ -153,7 +153,7 @@ internal class NewContact {
...
@@ -153,7 +153,7 @@ internal class NewContact {
operator
fun
invoke
(
operator
fun
invoke
(
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
event
:
NewGroup
Event
,
event
:
MemberJoinRequest
Event
,
accept
:
Boolean
?,
accept
:
Boolean
?,
blackList
:
Boolean
=
false
blackList
:
Boolean
=
false
)
=
)
=
...
@@ -174,8 +174,8 @@ internal class NewContact {
...
@@ -174,8 +174,8 @@ internal class NewContact {
),
),
groupMsgType
=
1
,
groupMsgType
=
1
,
language
=
1000
,
language
=
1000
,
msgSeq
=
event
.
seq
,
msgSeq
=
event
.
eventId
,
reqUin
=
event
.
i
d
,
reqUin
=
event
.
fromI
d
,
srcId
=
3
,
srcId
=
3
,
subSrcId
=
31
,
subSrcId
=
31
,
subType
=
1
subType
=
1
...
...
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt
View file @
6480e78b
...
@@ -6,8 +6,8 @@ import kotlinx.coroutines.CoroutineScope
...
@@ -6,8 +6,8 @@ import kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.coroutines.io.ByteReadChannel
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.event.events.
NewFriend
Event
import
net.mamoe.mirai.event.events.
MemberJoinRequest
Event
import
net.mamoe.mirai.event.events.New
Group
Event
import
net.mamoe.mirai.event.events.New
FriendRequest
Event
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.message.data.MessageChain
...
@@ -208,7 +208,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -208,7 +208,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param event 好友验证的事件对象
* @param event 好友验证的事件对象
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
acceptNewFriend
(
event
:
NewFriend
Event
)
actual
abstract
suspend
fun
acceptNewFriend
Request
(
event
:
NewFriendRequest
Event
)
/**
/**
* 拒绝好友验证
* 拒绝好友验证
...
@@ -217,7 +217,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -217,7 +217,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param blackList 拒绝后是否拉入黑名单
* @param blackList 拒绝后是否拉入黑名单
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
rejectNewFriend
(
event
:
NewFriend
Event
,
blackList
:
Boolean
)
actual
abstract
suspend
fun
rejectNewFriend
Request
(
event
:
NewFriendRequest
Event
,
blackList
:
Boolean
)
/**
/**
* 通过加群验证(需管理员权限)
* 通过加群验证(需管理员权限)
...
@@ -225,7 +225,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -225,7 +225,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param event 加群验证的事件对象
* @param event 加群验证的事件对象
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
accept
NewGroup
(
event
:
NewGroup
Event
)
actual
abstract
suspend
fun
accept
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
)
/**
/**
* 拒绝加群验证(需管理员权限)
* 拒绝加群验证(需管理员权限)
...
@@ -234,7 +234,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -234,7 +234,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param blackList 拒绝后是否拉入黑名单
* @param blackList 拒绝后是否拉入黑名单
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
reject
NewGroup
(
event
:
NewGroup
Event
,
blackList
:
Boolean
)
actual
abstract
suspend
fun
reject
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
,
blackList
:
Boolean
)
/**
/**
* 忽略加群验证(需管理员权限)
* 忽略加群验证(需管理员权限)
...
@@ -243,5 +243,5 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -243,5 +243,5 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param blackList 忽略后是否拉入黑名单
* @param blackList 忽略后是否拉入黑名单
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
ignore
NewGroup
(
event
:
NewGroup
Event
,
blackList
:
Boolean
)
actual
abstract
suspend
fun
ignore
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
,
blackList
:
Boolean
)
}
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
6480e78b
...
@@ -18,8 +18,8 @@ import kotlinx.coroutines.io.ByteReadChannel
...
@@ -18,8 +18,8 @@ import kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.event.events.
NewFriend
Event
import
net.mamoe.mirai.event.events.
MemberJoinRequest
Event
import
net.mamoe.mirai.event.events.New
Group
Event
import
net.mamoe.mirai.event.events.New
FriendRequest
Event
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.BotNetworkHandler
...
@@ -208,7 +208,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
...
@@ -208,7 +208,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
*/
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
@JvmSynthetic
@JvmSynthetic
abstract
suspend
fun
acceptNewFriend
(
event
:
NewFriend
Event
)
abstract
suspend
fun
acceptNewFriend
Request
(
event
:
NewFriendRequest
Event
)
/**
/**
* 拒绝好友验证
* 拒绝好友验证
...
@@ -218,7 +218,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
...
@@ -218,7 +218,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
*/
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
@JvmSynthetic
@JvmSynthetic
abstract
suspend
fun
rejectNewFriend
(
event
:
NewFriend
Event
,
blackList
:
Boolean
=
false
)
abstract
suspend
fun
rejectNewFriend
Request
(
event
:
NewFriendRequest
Event
,
blackList
:
Boolean
=
false
)
/**
/**
* 通过加群验证(需管理员权限)
* 通过加群验证(需管理员权限)
...
@@ -227,7 +227,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
...
@@ -227,7 +227,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
*/
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
@JvmSynthetic
@JvmSynthetic
abstract
suspend
fun
accept
NewGroup
(
event
:
NewGroup
Event
)
abstract
suspend
fun
accept
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
)
/**
/**
* 拒绝加群验证(需管理员权限)
* 拒绝加群验证(需管理员权限)
...
@@ -237,7 +237,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
...
@@ -237,7 +237,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
*/
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
@JvmSynthetic
@JvmSynthetic
abstract
suspend
fun
reject
NewGroup
(
event
:
NewGroup
Event
,
blackList
:
Boolean
=
false
)
abstract
suspend
fun
reject
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
,
blackList
:
Boolean
=
false
)
/**
/**
* 忽略加群验证(需管理员权限)
* 忽略加群验证(需管理员权限)
...
@@ -247,7 +247,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
...
@@ -247,7 +247,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
*/
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
@JvmSynthetic
@JvmSynthetic
abstract
suspend
fun
ignore
NewGroup
(
event
:
NewGroup
Event
,
blackList
:
Boolean
=
false
)
abstract
suspend
fun
ignore
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
,
blackList
:
Boolean
=
false
)
// endregion
// endregion
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
View file @
6480e78b
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
package
net.mamoe.mirai.event.events
package
net.mamoe.mirai.event.events
import
kotlinx.atomicfu.AtomicBoolean
import
kotlinx.atomicfu.atomic
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.JavaFriendlyAPI
import
net.mamoe.mirai.JavaFriendlyAPI
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
...
@@ -482,63 +484,112 @@ data class MemberUnmuteEvent(
...
@@ -482,63 +484,112 @@ data class MemberUnmuteEvent(
// region 好友、群认证
// region 好友、群认证
/**
* 一个账号请求添加机器人为好友的事件
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
data class
NewFriendEvent
(
data class
NewFriend
Request
Event
(
override
val
bot
:
Bot
,
override
val
bot
:
Bot
,
val
seq
:
Long
,
// 事件唯一识别
/**
val
additional
:
String
,
* 事件唯一识别号
val
id
:
Long
,
*/
val
groupName
:
String
,
val
eventId
:
Long
,
/**
* 入群申请消息
*/
val
message
:
String
,
/**
* 请求人 [QQ.id]
*/
val
fromId
:
Long
,
/**
* 来自群 [Group.id], 其他途径时为 0
*/
val
fromGroupId
:
Long
,
/**
* 群名片或好友昵称
*/
val
nick
:
String
val
nick
:
String
)
:
BotEvent
,
Packet
{
)
:
BotEvent
,
Packet
{
internal
val
responded
:
AtomicBoolean
=
atomic
(
false
)
/**
* @return 申请人来自的群. 当申请人来自其他途径申请时为 `null`
*/
val
fromGroup
:
Group
?
=
if
(
fromGroupId
==
0L
)
null
else
bot
.
getGroup
(
fromGroupId
)
@JvmSynthetic
@JvmSynthetic
suspend
fun
accept
()
=
bot
.
acceptNewFriend
(
this
)
suspend
fun
accept
()
=
bot
.
acceptNewFriend
Request
(
this
)
@JvmSynthetic
@JvmSynthetic
suspend
fun
reject
(
blackList
:
Boolean
=
false
)
=
bot
.
rejectNewFriend
(
this
,
blackList
)
suspend
fun
reject
(
blackList
:
Boolean
=
false
)
=
bot
.
rejectNewFriend
Request
(
this
,
blackList
)
@JavaFriendlyAPI
@JavaFriendlyAPI
@JvmName
(
"accept"
)
@JvmName
(
"accept"
)
fun
`
__
accept
blocking
for
java
__`
()
=
runBlocking
{
bot
.
acceptNewFriend
(
this
@NewFriendEvent
)
}
fun
`
__
accept
blocking
for
java
__`
()
=
runBlocking
{
accept
(
)
}
@JavaFriendlyAPI
@JavaFriendlyAPI
@JvmOverloads
@JvmOverloads
@JvmName
(
"reject"
)
@JvmName
(
"reject"
)
fun
`
__
reject
blocking
for
java
__`
(
blackList
:
Boolean
=
false
)
=
fun
`
__
reject
blocking
for
java
__`
(
blackList
:
Boolean
=
false
)
=
runBlocking
{
bot
.
rejectNewFriend
(
this
@NewFriendEvent
,
blackList
)
}
runBlocking
{
reject
(
blackList
)
}
}
}
/**
* 机器人被邀请加入群
*/
@SinceMirai
(
"0.35.0"
)
@SinceMirai
(
"0.35.0"
)
data class
NewGroup
Event
(
data class
MemberJoinRequest
Event
(
override
val
bot
:
Bot
,
override
val
bot
:
Bot
,
val
seq
:
Long
,
// 事件唯一识别
/**
val
additional
:
String
,
* 事件唯一识别号
val
id
:
Long
,
*/
val
eventId
:
Long
,
/**
* 入群申请消息
*/
val
message
:
String
,
/**
* 申请入群的账号的 id
*/
val
fromId
:
Long
,
val
groupId
:
Long
,
val
groupId
:
Long
,
val
groupName
:
String
,
val
groupName
:
String
,
val
nick
:
String
/**
* 申请人昵称
*/
val
fromNick
:
String
)
:
BotEvent
,
Packet
{
)
:
BotEvent
,
Packet
{
suspend
fun
accept
()
=
bot
.
acceptNewGroup
(
this
)
val
group
:
Group
=
this
.
bot
.
getGroup
(
groupId
)
suspend
fun
reject
(
blackList
:
Boolean
=
false
)
=
bot
.
rejectNewGroup
(
this
,
blackList
)
suspend
fun
ignore
(
blackList
:
Boolean
=
false
)
=
bot
.
ignoreNewGroup
(
this
,
blackList
)
internal
val
responded
:
AtomicBoolean
=
atomic
(
false
)
@JvmSynthetic
suspend
fun
accept
()
=
bot
.
acceptMemberJoinRequest
(
this
)
@JvmSynthetic
suspend
fun
reject
(
blackList
:
Boolean
=
false
)
=
bot
.
rejectMemberJoinRequest
(
this
,
blackList
)
@JvmSynthetic
suspend
fun
ignore
(
blackList
:
Boolean
=
false
)
=
bot
.
ignoreMemberJoinRequest
(
this
,
blackList
)
@JavaFriendlyAPI
@JavaFriendlyAPI
@JvmName
(
"accept"
)
@JvmName
(
"accept"
)
fun
`
__
accept
blocking
for
java
__`
()
=
runBlocking
{
bot
.
accept
NewGroup
(
this
@NewGroup
Event
)
}
fun
`
__
accept
blocking
for
java
__`
()
=
runBlocking
{
bot
.
accept
MemberJoinRequest
(
this
@MemberJoinRequest
Event
)
}
@JavaFriendlyAPI
@JavaFriendlyAPI
@JvmOverloads
@JvmOverloads
@JvmName
(
"reject"
)
@JvmName
(
"reject"
)
fun
`
__
reject
blocking
for
java
__`
(
blackList
:
Boolean
=
false
)
=
fun
`
__
reject
blocking
for
java
__`
(
blackList
:
Boolean
=
false
)
=
runBlocking
{
bot
.
reject
NewGroup
(
this
@NewGroup
Event
,
blackList
)
}
runBlocking
{
bot
.
reject
MemberJoinRequest
(
this
@MemberJoinRequest
Event
,
blackList
)
}
@JavaFriendlyAPI
@JavaFriendlyAPI
@JvmOverloads
@JvmOverloads
@JvmName
(
"ignore"
)
@JvmName
(
"ignore"
)
fun
`
__
ignore
blocking
for
java
__`
(
blackList
:
Boolean
=
false
)
=
fun
`
__
ignore
blocking
for
java
__`
(
blackList
:
Boolean
=
false
)
=
runBlocking
{
bot
.
ignore
NewGroup
(
this
@NewGroup
Event
,
blackList
)
}
runBlocking
{
bot
.
ignore
MemberJoinRequest
(
this
@MemberJoinRequest
Event
,
blackList
)
}
}
}
// endregion 好友、群认证
// endregion 好友、群认证
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
View file @
6480e78b
...
@@ -6,8 +6,8 @@ import kotlinx.coroutines.CoroutineScope
...
@@ -6,8 +6,8 @@ import kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.coroutines.io.ByteReadChannel
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.event.events.NewFriendEvent
import
net.mamoe.mirai.event.events.NewFriend
Request
Event
import
net.mamoe.mirai.event.events.
NewGroup
Event
import
net.mamoe.mirai.event.events.
MemberJoinRequest
Event
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.BotNetworkHandler
...
@@ -216,7 +216,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -216,7 +216,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param event 好友验证的事件对象
* @param event 好友验证的事件对象
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
acceptNewFriend
(
event
:
NewFriend
Event
)
actual
abstract
suspend
fun
acceptNewFriend
Request
(
event
:
NewFriendRequest
Event
)
/**
/**
* 拒绝好友验证
* 拒绝好友验证
...
@@ -225,7 +225,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -225,7 +225,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param blackList 拒绝后是否拉入黑名单
* @param blackList 拒绝后是否拉入黑名单
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
rejectNewFriend
(
event
:
NewFriend
Event
,
blackList
:
Boolean
)
actual
abstract
suspend
fun
rejectNewFriend
Request
(
event
:
NewFriendRequest
Event
,
blackList
:
Boolean
)
/**
/**
* 通过加群验证(需管理员权限)
* 通过加群验证(需管理员权限)
...
@@ -233,7 +233,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -233,7 +233,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param event 加群验证的事件对象
* @param event 加群验证的事件对象
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
accept
NewGroup
(
event
:
NewGroup
Event
)
actual
abstract
suspend
fun
accept
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
)
/**
/**
* 拒绝加群验证(需管理员权限)
* 拒绝加群验证(需管理员权限)
...
@@ -242,7 +242,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -242,7 +242,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param blackList 拒绝后是否拉入黑名单
* @param blackList 拒绝后是否拉入黑名单
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
reject
NewGroup
(
event
:
NewGroup
Event
,
blackList
:
Boolean
)
actual
abstract
suspend
fun
reject
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
,
blackList
:
Boolean
)
/**
/**
* 忽略加群验证(需管理员权限)
* 忽略加群验证(需管理员权限)
...
@@ -251,5 +251,5 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
...
@@ -251,5 +251,5 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
* @param blackList 忽略后是否拉入黑名单
* @param blackList 忽略后是否拉入黑名单
*/
*/
@JvmSynthetic
@JvmSynthetic
actual
abstract
suspend
fun
ignore
NewGroup
(
event
:
NewGroup
Event
,
blackList
:
Boolean
)
actual
abstract
suspend
fun
ignore
MemberJoinRequest
(
event
:
MemberJoinRequest
Event
,
blackList
:
Boolean
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment