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
086f04e1
Commit
086f04e1
authored
Feb 20, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add member.muteTimeRemaining
parent
2eee24c7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
20 deletions
+71
-20
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+14
-4
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
+13
-9
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
+34
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/MemberInfo.kt
.../src/commonMain/kotlin/net.mamoe.mirai/data/MemberInfo.kt
+2
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
...mmonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
+8
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
086f04e1
...
@@ -180,6 +180,15 @@ internal class MemberImpl(
...
@@ -180,6 +180,15 @@ internal class MemberImpl(
internal
var
_nameCard
:
String
=
memberInfo
.
nameCard
internal
var
_nameCard
:
String
=
memberInfo
.
nameCard
internal
var
_specialTitle
:
String
=
memberInfo
.
specialTitle
internal
var
_specialTitle
:
String
=
memberInfo
.
specialTitle
var
_muteTimestamp
:
Int
=
memberInfo
.
muteTimestamp
override
val
muteTimeRemaining
:
Int
=
if
(
_muteTimestamp
==
0
||
_muteTimestamp
==
0
xFFFFFFFF
.
toInt
())
{
0
}
else
{
_muteTimestamp
-
currentTimeSeconds
.
toInt
()
-
bot
.
client
.
timeDifference
.
toInt
()
}
override
var
nameCard
:
String
override
var
nameCard
:
String
get
()
=
_nameCard
get
()
=
_nameCard
set
(
newValue
)
{
set
(
newValue
)
{
...
@@ -215,7 +224,7 @@ internal class MemberImpl(
...
@@ -215,7 +224,7 @@ internal class MemberImpl(
newValue
newValue
).
sendWithoutExpect
()
).
sendWithoutExpect
()
}
}
MemberSpecialTitleChangeEvent
(
oldValue
,
newValue
,
this
@MemberImpl
).
broadcast
()
MemberSpecialTitleChangeEvent
(
oldValue
,
newValue
,
this
@MemberImpl
,
null
).
broadcast
()
}
}
}
}
}
}
...
@@ -293,6 +302,7 @@ internal class MemberInfoImpl(
...
@@ -293,6 +302,7 @@ internal class MemberInfoImpl(
else
->
MemberPermission
.
MEMBER
else
->
MemberPermission
.
MEMBER
}
}
override
val
specialTitle
:
String
get
()
=
jceInfo
.
sSpecialTitle
?:
""
override
val
specialTitle
:
String
get
()
=
jceInfo
.
sSpecialTitle
?:
""
override
val
muteTimestamp
:
Int
get
()
=
jceInfo
.
dwShutupTimestap
?.
toInt
()
?:
0
}
}
/**
/**
...
@@ -315,13 +325,13 @@ internal class GroupImpl(
...
@@ -315,13 +325,13 @@ internal class GroupImpl(
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
override
lateinit
var
botPermission
:
MemberPermission
override
lateinit
var
botPermission
:
MemberPermission
var
_botMute
Remaining
:
Int
=
groupInfo
.
botMuteRemaining
var
_botMute
Timestamp
:
Int
=
groupInfo
.
botMuteRemaining
override
val
botMuteRemaining
:
Int
=
override
val
botMuteRemaining
:
Int
=
if
(
_botMute
Remaining
==
0
||
_botMuteRemaining
==
0
xFFFFFFFF
.
toInt
())
{
if
(
_botMute
Timestamp
==
0
||
_botMuteTimestamp
==
0
xFFFFFFFF
.
toInt
())
{
0
0
}
else
{
}
else
{
_botMute
Remaining
-
currentTimeSeconds
.
toInt
()
-
bot
.
client
.
timeDifference
.
toInt
()
_botMute
Timestamp
-
currentTimeSeconds
.
toInt
()
-
bot
.
client
.
timeDifference
.
toInt
()
}
}
override
val
members
:
ContactList
<
Member
>
=
ContactList
(
members
.
mapNotNull
{
override
val
members
:
ContactList
<
Member
>
=
ContactList
(
members
.
mapNotNull
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
View file @
086f04e1
...
@@ -181,12 +181,12 @@ internal class OnlinePush {
...
@@ -181,12 +181,12 @@ internal class OnlinePush {
}
}
}
else
{
}
else
{
if
(
target
==
bot
.
uin
)
{
if
(
target
==
bot
.
uin
)
{
if
(
group
.
_botMute
Remaining
!=
time
)
{
if
(
group
.
_botMute
Timestamp
!=
time
)
{
if
(
time
==
0
)
{
if
(
time
==
0
)
{
group
.
_botMute
Remaining
=
0
group
.
_botMute
Timestamp
=
0
return
@
mapNotNull
BotUnmuteEvent
(
operator
)
as
Packet
return
@
mapNotNull
BotUnmuteEvent
(
operator
)
as
Packet
}
else
{
}
else
{
group
.
_botMute
Remaining
=
time
group
.
_botMute
Timestamp
=
time
return
@
mapNotNull
BotMuteEvent
(
durationSeconds
=
time
,
operator
=
operator
)
as
Packet
return
@
mapNotNull
BotMuteEvent
(
durationSeconds
=
time
,
operator
=
operator
)
as
Packet
}
}
}
else
{
}
else
{
...
@@ -194,11 +194,17 @@ internal class OnlinePush {
...
@@ -194,11 +194,17 @@ internal class OnlinePush {
}
}
}
else
{
}
else
{
val
member
=
group
[
target
]
val
member
=
group
[
target
]
// TODO: 2020/2/20 检查是否重复
member
as
MemberImpl
return
@
mapNotNull
if
(
time
==
0
)
{
if
(
member
.
_muteTimestamp
!=
time
)
{
MemberUnmuteEvent
(
operator
=
operator
,
member
=
member
)
if
(
time
==
0
)
{
member
.
_muteTimestamp
=
0
return
@
mapNotNull
MemberUnmuteEvent
(
member
,
operator
)
as
Packet
}
else
{
member
.
_muteTimestamp
=
time
return
@
mapNotNull
MemberMuteEvent
(
member
,
time
,
operator
)
as
Packet
}
}
else
{
}
else
{
MemberMuteEvent
(
operator
=
operator
,
member
=
member
,
durationSeconds
=
time
)
as
Packet
return
@
mapNotNull
null
}
}
}
}
}
}
...
@@ -261,7 +267,6 @@ internal class OnlinePush {
...
@@ -261,7 +267,6 @@ internal class OnlinePush {
return
@
mapNotNull
null
return
@
mapNotNull
null
}
}
}
}
return
@
mapNotNull
null
}
}
msgInfo
.
shMsgType
.
toInt
()
==
528
->
{
msgInfo
.
shMsgType
.
toInt
()
==
528
->
{
bot
.
network
.
logger
.
debug
{
"unknown shtype ${msgInfo.shMsgType.toInt()}"
}
bot
.
network
.
logger
.
debug
{
"unknown shtype ${msgInfo.shMsgType.toInt()}"
}
...
@@ -274,7 +279,6 @@ internal class OnlinePush {
...
@@ -274,7 +279,6 @@ internal class OnlinePush {
return
@
mapNotNull
null
return
@
mapNotNull
null
}
}
}
}
return
@
mapNotNull
null
}
}
}
}
return
MultiPacket
(
packets
)
return
MultiPacket
(
packets
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
View file @
086f04e1
/*
/*
* Copyright 2020 Mamoe Technologies and contributors.
* Copyright 2020 Mamoe Technologies and contributors.
*
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可
以
在以下链接找到该许可证.
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
...
@@ -29,33 +29,50 @@ interface Member : QQ, Contact {
...
@@ -29,33 +29,50 @@ interface Member : QQ, Contact {
/**
/**
* 成员的权限, 动态更新.
* 成员的权限, 动态更新.
*
* @see MemberPermissionChangeEvent 权限变更事件. 由群主或机器人的操作触发.
*/
*/
val
permission
:
MemberPermission
val
permission
:
MemberPermission
/**
/**
* 群名片. 可能为空. 修改时将会触发事件
* 群名片. 可能为空.
*
* 管理员和群主都可修改任何人(包括群主)的群名片.
*
*
* 在修改时将会异步上传至服务器.
* 在修改时将会异步上传至服务器.
*
*
* @see [nameCardOrNick] 获取非空群名片或昵称
* @see [nameCardOrNick] 获取非空群名片或昵称
*
*
* @see MemberCardChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件
* @see MemberCardChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件
. 修改时也会触发此事件.
* @throws PermissionDeniedException 无权限修改时
* @throws PermissionDeniedException 无权限修改时
*/
*/
var
nameCard
:
String
var
nameCard
:
String
/**
/**
* 群头衔
* 群头衔.
*
* 仅群主可以修改群头衔.
*
*
* 在修改时将会异步上传至服务器.
* 在修改时将会异步上传至服务器.
*
*
* @see MemberSpecialTitleChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件
* @see MemberSpecialTitleChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件
. 修改时也会触发此事件.
* @throws PermissionDeniedException 无权限修改时
* @throws PermissionDeniedException 无权限修改时
*/
*/
var
specialTitle
:
String
var
specialTitle
:
String
/**
/**
* 禁言
* 被禁言剩余时长. 单位为秒.
*
* @see isMuted 判断改成员是否处于禁言状态
* @see mute 设置禁言
* @see unmute 取消禁言
*/
val
muteTimeRemaining
:
Int
/**
* 禁言.
*
* 管理员可禁言成员, 群主可禁言管理员和群员.
*
*
* @param durationSeconds 持续时间. 精确到秒. 范围区间表示为 `(0s, 30days]`. 超过范围则会抛出异常.
* @param durationSeconds 持续时间. 精确到秒. 范围区间表示为 `(0s, 30days]`. 超过范围则会抛出异常.
* @return 机器人无权限时返回 `false`
* @return 机器人无权限时返回 `false`
...
@@ -72,6 +89,8 @@ interface Member : QQ, Contact {
...
@@ -72,6 +89,8 @@ interface Member : QQ, Contact {
/**
/**
* 解除禁言.
* 解除禁言.
*
*
* 管理员可解除成员的禁言, 群主可解除管理员和群员的禁言.
*
* @see MemberUnmuteEvent 成员被取消禁言事件.
* @see MemberUnmuteEvent 成员被取消禁言事件.
* @throws PermissionDeniedException 无权限修改时
* @throws PermissionDeniedException 无权限修改时
*/
*/
...
@@ -80,6 +99,8 @@ interface Member : QQ, Contact {
...
@@ -80,6 +99,8 @@ interface Member : QQ, Contact {
/**
/**
* 踢出该成员.
* 踢出该成员.
*
*
* 管理员可踢出成员, 群主可踢出管理员和群员.
*
* @see MemberLeaveEvent.Kick 成员被踢出事件.
* @see MemberLeaveEvent.Kick 成员被踢出事件.
* @throws PermissionDeniedException 无权限修改时
* @throws PermissionDeniedException 无权限修改时
*/
*/
...
@@ -98,6 +119,13 @@ interface Member : QQ, Contact {
...
@@ -98,6 +119,13 @@ interface Member : QQ, Contact {
*/
*/
val
Member
.
nameCardOrNick
:
String
get
()
=
this
.
nameCard
.
takeIf
{
it
.
isNotEmpty
()
}
?:
this
.
nick
val
Member
.
nameCardOrNick
:
String
get
()
=
this
.
nameCard
.
takeIf
{
it
.
isNotEmpty
()
}
?:
this
.
nick
/**
* 判断改成员是否处于禁言状态.
*/
fun
Member
.
isMuted
():
Boolean
{
return
muteTimeRemaining
!=
0
&&
muteTimeRemaining
!=
0
xFFFFFFFF
.
toInt
()
}
@ExperimentalTime
@ExperimentalTime
suspend
inline
fun
Member
.
mute
(
duration
:
Duration
)
{
suspend
inline
fun
Member
.
mute
(
duration
:
Duration
)
{
require
(
duration
.
inDays
<=
30
)
{
"duration must be at most 1 month"
}
require
(
duration
.
inDays
<=
30
)
{
"duration must be at most 1 month"
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/MemberInfo.kt
View file @
086f04e1
...
@@ -17,4 +17,6 @@ interface MemberInfo : FriendInfo {
...
@@ -17,4 +17,6 @@ interface MemberInfo : FriendInfo {
val
permission
:
MemberPermission
val
permission
:
MemberPermission
val
specialTitle
:
String
val
specialTitle
:
String
val
muteTimestamp
:
Int
}
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt
View file @
086f04e1
...
@@ -333,7 +333,14 @@ data class MemberSpecialTitleChangeEvent(
...
@@ -333,7 +333,14 @@ data class MemberSpecialTitleChangeEvent(
*/
*/
val
new
:
String
,
val
new
:
String
,
override
val
member
:
Member
override
val
member
:
Member
,
/**
* 操作人.
* 不为 null 时一定为群主. 可能与 [member] 引用相同, 此时为群员自己修改.
* 为 null 时则是机器人操作.
*/
val
operator
:
Member
?
)
:
GroupMemberEvent
)
:
GroupMemberEvent
// endregion
// endregion
...
...
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