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
45d5131e
Commit
45d5131e
authored
Feb 15, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unified exception throw
parent
f989cd93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
18 deletions
+24
-18
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+7
-9
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
...re/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
+3
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
+14
-9
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
45d5131e
...
...
@@ -227,9 +227,9 @@ internal class MemberImpl(
override
val
bot
:
QQAndroidBot
get
()
=
qq
.
bot
override
suspend
fun
mute
(
durationSeconds
:
Int
)
:
Boolean
{
override
suspend
fun
mute
(
durationSeconds
:
Int
)
{
if
(
group
.
botPermission
!=
MemberPermission
.
OWNER
&&
(!
group
.
botPermission
.
isOperator
()
||
this
.
isOperator
()))
{
return
false
throw
PermissionDeniedException
()
}
bot
.
network
.
run
{
...
...
@@ -243,12 +243,11 @@ internal class MemberImpl(
@Suppress
(
"RemoveRedundantQualifierName"
)
// or unresolved reference
net
.
mamoe
.
mirai
.
event
.
events
.
MemberMuteEvent
(
this
@MemberImpl
,
durationSeconds
,
null
).
broadcast
()
return
true
}
override
suspend
fun
unmute
()
:
Boolean
{
override
suspend
fun
unmute
()
{
if
(
group
.
botPermission
!=
MemberPermission
.
OWNER
&&
(!
group
.
botPermission
.
isOperator
()
||
this
.
isOperator
()))
{
return
false
throw
PermissionDeniedException
()
}
bot
.
network
.
run
{
...
...
@@ -262,16 +261,15 @@ internal class MemberImpl(
@Suppress
(
"RemoveRedundantQualifierName"
)
// or unresolved reference
net
.
mamoe
.
mirai
.
event
.
events
.
MemberUnmuteEvent
(
this
@MemberImpl
,
null
).
broadcast
()
return
true
}
override
suspend
fun
kick
(
message
:
String
)
:
Boolean
{
override
suspend
fun
kick
(
message
:
String
)
{
if
(
group
.
botPermission
!=
MemberPermission
.
OWNER
&&
(!
group
.
botPermission
.
isOperator
()
||
this
.
isOperator
()))
{
return
false
throw
PermissionDeniedException
()
}
bot
.
network
.
run
{
return
TroopManagement
.
Kick
(
TroopManagement
.
Kick
(
client
=
bot
.
client
,
member
=
this
@MemberImpl
,
message
=
message
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
View file @
45d5131e
...
...
@@ -16,6 +16,7 @@ import net.mamoe.mirai.data.MemberInfo
import
net.mamoe.mirai.event.events.*
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmStatic
/**
* 群. 在 QQ Android 中叫做 "Troop"
...
...
@@ -145,6 +146,7 @@ interface Group : Contact, CoroutineScope {
/**
* by @kar98k
*/
@JvmStatic
fun
calculateGroupUinByGroupCode
(
groupCode
:
Long
):
Long
{
var
left
:
Long
=
groupCode
/
1000000L
...
...
@@ -161,6 +163,7 @@ interface Group : Contact, CoroutineScope {
return
left
*
1000000L
+
groupCode
%
1000000L
}
@JvmStatic
fun
calculateGroupCodeByGroupUin
(
groupUin
:
Long
):
Long
{
var
left
:
Long
=
groupUin
/
1000000L
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
View file @
45d5131e
...
...
@@ -35,20 +35,22 @@ interface Member : QQ, Contact {
/**
* 群名片. 可能为空. 修改时将会触发事件
*
* 在修改时将会异步上传至服务器.
无权限修改时将会抛出异常 [PermissionDeniedException]
* 在修改时将会异步上传至服务器.
*
* @see [groupCardOrNick] 获取非空群名片或昵称
*
* @see MemberCardChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件
* @throws PermissionDeniedException 无权限修改时
*/
var
nameCard
:
String
/**
* 群头衔
*
* 在修改时将会异步上传至服务器.
无权限修改时将会抛出异常 [PermissionDeniedException]
* 在修改时将会异步上传至服务器.
*
* @see MemberSpecialTitleChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件
* @throws PermissionDeniedException 无权限修改时
*/
var
specialTitle
:
String
...
...
@@ -63,22 +65,25 @@ interface Member : QQ, Contact {
* @see Int.daysToSeconds
*
* @see MemberMuteEvent 成员被禁言事件
* @throws PermissionDeniedException 无权限修改时
*/
suspend
fun
mute
(
durationSeconds
:
Int
)
:
Boolean
suspend
fun
mute
(
durationSeconds
:
Int
)
/**
* 解除禁言.
机器人无权限时返回 `false`.
* 解除禁言.
*
* @see MemberUnmuteEvent 成员被取消禁言事件.
* @throws PermissionDeniedException 无权限修改时
*/
suspend
fun
unmute
()
:
Boolean
suspend
fun
unmute
()
/**
* 踢出该成员.
机器人无权限时返回 `false`.
* 踢出该成员.
*
* @see MemberLeaveEvent.Kick 成员被踢出事件.
* @throws PermissionDeniedException 无权限修改时
*/
suspend
fun
kick
(
message
:
String
=
""
)
:
Boolean
suspend
fun
kick
(
message
:
String
=
""
)
/**
* 当且仅当 `[other] is [Member] && [other].id == this.id && [other].group == this.group` 时为 true
...
...
@@ -94,10 +99,10 @@ interface Member : QQ, Contact {
val
Member
.
groupCardOrNick
:
String
get
()
=
this
.
nameCard
.
takeIf
{
it
.
isNotEmpty
()
}
?:
this
.
nick
@ExperimentalTime
suspend
inline
fun
Member
.
mute
(
duration
:
Duration
)
:
Boolean
{
suspend
inline
fun
Member
.
mute
(
duration
:
Duration
)
{
require
(
duration
.
inDays
<=
30
)
{
"duration must be at most 1 month"
}
require
(
duration
.
inSeconds
>
0
)
{
"duration must be greater than 0 second"
}
return
this
.
mute
(
duration
.
inSeconds
.
toInt
())
this
.
mute
(
duration
.
inSeconds
.
toInt
())
}
suspend
inline
fun
Member
.
mute
(
durationSeconds
:
Long
)
=
this
.
mute
(
durationSeconds
.
toInt
())
\ 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