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
9b3bc88b
Commit
9b3bc88b
authored
Feb 17, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Bot.closeAndJoin
parent
7d283808
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+14
-0
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
9b3bc88b
...
@@ -236,6 +236,8 @@ abstract class Bot : CoroutineScope {
...
@@ -236,6 +236,8 @@ abstract class Bot : CoroutineScope {
* 注: 不可重新登录. 必须重新实例化一个 [Bot].
* 注: 不可重新登录. 必须重新实例化一个 [Bot].
*
*
* @param cause 原因. 为 null 时视为正常关闭, 非 null 时视为异常关闭
* @param cause 原因. 为 null 时视为正常关闭, 非 null 时视为异常关闭
*
* @see closeAndJoin
*/
*/
abstract
fun
close
(
cause
:
Throwable
?
=
null
)
abstract
fun
close
(
cause
:
Throwable
?
=
null
)
...
@@ -260,6 +262,18 @@ abstract class Bot : CoroutineScope {
...
@@ -260,6 +262,18 @@ abstract class Bot : CoroutineScope {
// endregion
// endregion
}
}
/**
* 关闭这个 [Bot], 停止一切相关活动. 所有引用都会被释放.
*
* 注: 不可重新登录. 必须重新实例化一个 [Bot].
*
* @param cause 原因. 为 null 时视为正常关闭, 非 null 时视为异常关闭
*/
suspend
inline
fun
Bot
.
closeAndJoin
(
cause
:
Throwable
?
=
null
)
{
close
(
cause
)
coroutineContext
[
Job
]
?.
join
()
}
inline
fun
Bot
.
containsFriend
(
id
:
Long
):
Boolean
=
this
.
qqs
.
contains
(
id
)
inline
fun
Bot
.
containsFriend
(
id
:
Long
):
Boolean
=
this
.
qqs
.
contains
(
id
)
inline
fun
Bot
.
containsGroup
(
id
:
Long
):
Boolean
=
this
.
groups
.
contains
(
id
)
inline
fun
Bot
.
containsGroup
(
id
:
Long
):
Boolean
=
this
.
groups
.
contains
(
id
)
...
...
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