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
ffcb48b8
Commit
ffcb48b8
authored
Nov 19, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add contract
parent
598b2907
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
.../src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
+11
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
View file @
ffcb48b8
...
@@ -21,6 +21,9 @@ import net.mamoe.mirai.utils.SuspendLazy
...
@@ -21,6 +21,9 @@ import net.mamoe.mirai.utils.SuspendLazy
import
net.mamoe.mirai.utils.internal.PositiveNumbers
import
net.mamoe.mirai.utils.internal.PositiveNumbers
import
net.mamoe.mirai.utils.internal.coerceAtLeastOrFail
import
net.mamoe.mirai.utils.internal.coerceAtLeastOrFail
import
net.mamoe.mirai.withSession
import
net.mamoe.mirai.withSession
import
kotlin.contracts.ExperimentalContracts
import
kotlin.contracts.InvocationKind
import
kotlin.contracts.contract
class
ContactList
<
C
:
Contact
>
:
MutableMap
<
UInt
,
C
>
by
mutableMapOf
()
class
ContactList
<
C
:
Contact
>
:
MutableMap
<
UInt
,
C
>
by
mutableMapOf
()
...
@@ -37,7 +40,7 @@ sealed class Contact(val bot: Bot, val id: UInt) {
...
@@ -37,7 +40,7 @@ sealed class Contact(val bot: Bot, val id: UInt) {
/**
/**
* 向这个对象发送消息.
* 向这个对象发送消息.
*
*
* 速度太快会被服务器
拒绝
(无响应). 在测试中不延迟地发送 6 条消息就会被屏蔽之后的数据包 1 秒左右.
* 速度太快会被服务器
屏蔽
(无响应). 在测试中不延迟地发送 6 条消息就会被屏蔽之后的数据包 1 秒左右.
*/
*/
abstract
suspend
fun
sendMessage
(
message
:
MessageChain
)
abstract
suspend
fun
sendMessage
(
message
:
MessageChain
)
...
@@ -108,7 +111,13 @@ class Group internal constructor(bot: Bot, val groupId: GroupId) : Contact(bot,
...
@@ -108,7 +111,13 @@ class Group internal constructor(bot: Bot, val groupId: GroupId) : Contact(bot,
* 以 [BotSession] 作为接收器 (receiver) 并调用 [block], 返回 [block] 的返回值.
* 以 [BotSession] 作为接收器 (receiver) 并调用 [block], 返回 [block] 的返回值.
* 这个方法将能帮助使用在 [BotSession] 中定义的一些扩展方法, 如 [BotSession.sendAndExpectAsync]
* 这个方法将能帮助使用在 [BotSession] 中定义的一些扩展方法, 如 [BotSession.sendAndExpectAsync]
*/
*/
inline
fun
<
R
>
Contact
.
withSession
(
block
:
BotSession
.()
->
R
):
R
=
bot
.
withSession
(
block
)
@UseExperimental
(
ExperimentalContracts
::
class
)
inline
fun
<
R
>
Contact
.
withSession
(
block
:
BotSession
.()
->
R
):
R
{
contract
{
callsInPlace
(
block
,
InvocationKind
.
EXACTLY_ONCE
)
}
return
bot
.
withSession
(
block
)
}
/**
/**
* QQ 对象.
* QQ 对象.
...
...
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