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
348d13a4
Commit
348d13a4
authored
Feb 12, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle event of new member joining
parent
3b0ee9ad
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
157 additions
and
40 deletions
+157
-40
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+10
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/TroopManagement.kt
...qqandroid/network/protocol/packet/chat/TroopManagement.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
...ndroid/network/protocol/packet/chat/receive/MessageSvc.kt
+85
-29
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
...ndroid/network/protocol/packet/chat/receive/OnlinePush.kt
+3
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
.../src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
+7
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
...re/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
+24
-8
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupInfo.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/data/GroupInfo.kt
+5
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
...mmonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
+22
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
348d13a4
...
...
@@ -325,6 +325,15 @@ internal class GroupImpl(
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
override
lateinit
var
botPermission
:
MemberPermission
var
_botMuteRemaining
:
Int
=
groupInfo
.
botMuteRemaining
override
val
botMuteRemaining
:
Int
=
if
(
_botMuteRemaining
==
0
||
_botMuteRemaining
==
0
xFFFFFFFF
.
toInt
())
{
0
}
else
{
_botMuteRemaining
-
currentTimeSeconds
.
toInt
()
-
bot
.
client
.
timeDifference
.
toInt
()
}
override
val
members
:
ContactList
<
Member
>
=
ContactList
(
members
.
mapNotNull
{
if
(
it
.
uin
==
bot
.
uin
)
{
botPermission
=
it
.
permission
...
...
@@ -487,6 +496,7 @@ internal class GroupImpl(
}
override
suspend
fun
sendMessage
(
message
:
MessageChain
)
{
check
(!
isBotMuted
)
{
"bot is muted. Remaining seconds=$botMuteRemaining"
}
val
event
=
GroupMessageSendEvent
(
this
,
message
).
broadcast
()
if
(
event
.
isCancelled
)
{
throw
EventCancelledException
(
"cancelled by FriendMessageSendEvent"
)
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/TroopManagement.kt
View file @
348d13a4
...
...
@@ -44,6 +44,7 @@ internal inline class GroupInfoImpl(
override
val
autoApprove
get
()
=
delegate
.
groupFlagext3
?.
and
(
0
x00100000
)
==
0
override
val
confessTalk
get
()
=
delegate
.
groupFlagext3
?.
and
(
0
x00002000
)
==
0
override
val
muteAll
:
Boolean
get
()
=
delegate
.
shutupTimestamp
!=
0
override
val
botMuteRemaining
:
Int
get
()
=
delegate
.
shutupTimestampMe
?:
0
}
internal
class
TroopManagement
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
View file @
348d13a4
This diff is collapsed.
Click to expand it.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
View file @
348d13a4
...
...
@@ -187,6 +187,9 @@ internal class OnlinePush {
)
}
}
else
{
if
(
target
==
bot
.
uin
)
{
}
val
member
=
group
[
target
]
if
(
time
==
0
)
{
MemberUnmuteEvent
(
operator
=
operator
,
member
=
member
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
View file @
348d13a4
...
...
@@ -14,6 +14,7 @@ package net.mamoe.mirai.contact
import
kotlinx.coroutines.CoroutineScope
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.event.events.BeforeImageUploadEvent
import
net.mamoe.mirai.event.events.EventCancelledException
import
net.mamoe.mirai.event.events.ImageUploadEvent
import
net.mamoe.mirai.event.events.MessageSendEvent.FriendMessageSendEvent
import
net.mamoe.mirai.event.events.MessageSendEvent.GroupMessageSendEvent
...
...
@@ -47,16 +48,20 @@ interface Contact : CoroutineScope {
*
* @see FriendMessageSendEvent 发送好友信息事件, cancellable
* @see GroupMessageSendEvent 发送群消息事件. cancellable
*
* @throws EventCancelledException 当发送消息事件被取消
* @throws IllegalStateException 发送群消息时若 [Bot] 被禁言抛出
*/
suspend
fun
sendMessage
(
message
:
MessageChain
)
/**
* 上传一个图片以备发送.
* TODO: 群图片与好友图片之间是否通用还不确定.
* TODO: 好友之间图片是否通用还不确定.
* TODO 群图片与好友图片在服务器上是通用的, 在 mirai 目前不通用.
*
* @see BeforeImageUploadEvent 图片发送前事件, cancellable
* @see ImageUploadEvent 图片发送完成事件
*
* @throws EventCancelledException 当发送消息事件被取消
*/
suspend
fun
uploadImage
(
image
:
ExternalImage
):
Image
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
View file @
348d13a4
...
...
@@ -24,18 +24,20 @@ interface Group : Contact, CoroutineScope {
/**
* 群名称.
*
* 在修改时将会异步上传至服务器.
无权限修改时将会抛出异常 [PermissionDeniedException]
* 在修改时将会异步上传至服务器.
* 频繁修改可能会被服务器拒绝.
*
* @see MemberPermissionChangeEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常
*/
var
name
:
String
/**
* 入群公告, 没有时为空字符串.
*
* 在修改时将会异步上传至服务器.
无权限修改时将会抛出异常 [PermissionDeniedException]
* 在修改时将会异步上传至服务器.
*
* @see GroupEntranceAnnouncementChangeEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常
*/
var
entranceAnnouncement
:
String
/**
...
...
@@ -49,17 +51,19 @@ interface Group : Contact, CoroutineScope {
/**
* 坦白说状态. `true` 为允许.
*
* 在修改时将会异步上传至服务器.
无权限修改时将会抛出异常 [PermissionDeniedException]
* 在修改时将会异步上传至服务器.
*
* @see GroupAllowConfessTalkEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常
*/
var
confessTalk
:
Boolean
/**
* 允许群员邀请好友入群的状态. `true` 为允许
*
* 在修改时将会异步上传至服务器.
无权限修改时将会抛出异常 [PermissionDeniedException]
* 在修改时将会异步上传至服务器.
*
* @see GroupAllowMemberInviteEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常
*/
var
allowMemberInvite
:
Boolean
/**
...
...
@@ -77,10 +81,17 @@ interface Group : Contact, CoroutineScope {
override
val
id
:
Long
/**
* 群主
(同步事件更新)
* 群主
*/
val
owner
:
Member
/**
* 机器人被禁言还剩余多少秒
*
* @see BotMuteEvent
* @see isBotMuted
*/
val
botMuteRemaining
:
Int
/**
* 机器人在这个群里的权限
...
...
@@ -124,7 +135,7 @@ interface Group : Contact, CoroutineScope {
* 非特殊情况请不要使用这个函数. 优先使用 [get].
*/
@MiraiExperimentalAPI
(
"dangerous"
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
,
"FunctionName"
)
@JvmName
(
"newMember"
)
fun
Member
(
memberInfo
:
MemberInfo
):
Member
...
...
@@ -168,4 +179,9 @@ interface Group : Contact, CoroutineScope {
@MiraiExperimentalAPI
fun
toFullString
():
String
=
"Group(id=${this.id}, name=$name, owner=${owner.id}, members=${members.idContentString})"
}
\ No newline at end of file
}
/**
* 返回机器人是否正在被禁言
*/
val
Group
.
isBotMuted
:
Boolean
get
()
=
this
.
botMuteRemaining
==
0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupInfo.kt
View file @
348d13a4
...
...
@@ -57,4 +57,9 @@ interface GroupInfo {
* 全员禁言
*/
val
muteAll
:
Boolean
/**
* 机器人被禁言还剩时间, 秒.
*/
val
botMuteRemaining
:
Int
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
View file @
348d13a4
...
...
@@ -18,6 +18,7 @@ import net.mamoe.mirai.event.CancellableEvent
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.utils.ExternalImage
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
@Suppress
(
"unused"
)
...
...
@@ -123,6 +124,26 @@ data class BotGroupPermissionChangeEvent(
val
new
:
MemberPermission
)
:
BotPassiveEvent
,
GroupEvent
,
Packet
/**
* Bot 被禁言
*/
data class
BotMuteEvent
(
val
durationSeconds
:
Int
,
override
val
group
:
Group
,
/**
* 操作人. 为 null 则为机器人操作
*/
val
operator
:
Member
?
)
:
GroupEvent
,
Packet
,
BotPassiveEvent
/**
* Bot 加入了一个新群
*/
@MiraiExperimentalAPI
data class
BotJoinGroupEvent
(
override
val
group
:
Group
)
:
BotPassiveEvent
,
GroupEvent
,
Packet
// region 群设置
/**
...
...
@@ -219,7 +240,7 @@ data class GroupAllowMemberInviteEvent(
/**
* 成员加入群的事件
*/
data class
MemberJoinEvent
(
override
val
member
:
Member
)
:
GroupMemberEvent
,
BotPassiveEvent
data class
MemberJoinEvent
(
override
val
member
:
Member
)
:
GroupMemberEvent
,
BotPassiveEvent
,
Packet
/**
* 成员离开群的事件
...
...
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