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
14f4f458
Commit
14f4f458
authored
Feb 21, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `delay` to `millis`
parent
0015f381
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
...re/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
+6
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
...mmonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
+29
-7
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
View file @
14f4f458
...
@@ -241,32 +241,32 @@ suspend inline fun Group.recall(message: MessageChain) = this.recall(message[Mes
...
@@ -241,32 +241,32 @@ suspend inline fun Group.recall(message: MessageChain) = this.recall(message[Mes
/**
/**
* 在一段时间后撤回这条消息.
* 在一段时间后撤回这条消息.
*
*
* @param
delay
延迟的时间, 单位为毫秒
* @param
millis
延迟的时间, 单位为毫秒
* @param coroutineContext 额外的 [CoroutineContext]
* @param coroutineContext 额外的 [CoroutineContext]
* @see recall
* @see recall
*/
*/
fun
Group
.
recallIn
(
fun
Group
.
recallIn
(
message
:
MessageSource
,
message
:
MessageSource
,
delay
:
Long
,
millis
:
Long
,
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
):
Job
=
this
.
launch
(
coroutineContext
+
CoroutineName
(
"MessageRecall"
))
{
):
Job
=
this
.
launch
(
coroutineContext
+
CoroutineName
(
"MessageRecall"
))
{
kotlinx
.
coroutines
.
delay
(
delay
)
kotlinx
.
coroutines
.
delay
(
millis
)
recall
(
message
)
recall
(
message
)
}
}
/**
/**
* 在一段时间后撤回这条消息.
* 在一段时间后撤回这条消息.
*
*
* @param
delay
延迟的时间, 单位为毫秒
* @param
millis
延迟的时间, 单位为毫秒
* @param coroutineContext 额外的 [CoroutineContext]
* @param coroutineContext 额外的 [CoroutineContext]
* @see recall
* @see recall
*/
*/
fun
Group
.
recallIn
(
fun
Group
.
recallIn
(
message
:
MessageChain
,
message
:
MessageChain
,
delay
:
Long
,
millis
:
Long
,
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
):
Job
=
this
.
launch
(
coroutineContext
+
CoroutineName
(
"MessageRecall"
))
{
):
Job
=
this
.
launch
(
coroutineContext
+
CoroutineName
(
"MessageRecall"
))
{
kotlinx
.
coroutines
.
delay
(
delay
)
kotlinx
.
coroutines
.
delay
(
millis
)
recall
(
message
)
recall
(
message
)
}
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
View file @
14f4f458
...
@@ -13,8 +13,7 @@ import kotlinx.atomicfu.atomic
...
@@ -13,8 +13,7 @@ import kotlinx.atomicfu.atomic
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.Job
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.message.data.quote
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.unsafeWeakRef
import
net.mamoe.mirai.utils.unsafeWeakRef
...
@@ -67,17 +66,17 @@ open class MessageReceipt<C : Contact>(
...
@@ -67,17 +66,17 @@ open class MessageReceipt<C : Contact>(
/**
/**
* 撤回这条消息. [recall] 或 [recallIn] 只能被调用一次.
* 撤回这条消息. [recall] 或 [recallIn] 只能被调用一次.
*
*
* @param
delay
延迟时间, 单位为毫秒
* @param
millis
延迟时间, 单位为毫秒
*
*
* @throws IllegalStateException 当此消息已经被撤回或正计划撤回时
* @throws IllegalStateException 当此消息已经被撤回或正计划撤回时
*/
*/
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
fun
recallIn
(
delay
:
Long
):
Job
{
fun
recallIn
(
millis
:
Long
):
Job
{
@Suppress
(
"BooleanLiteralArgument"
)
@Suppress
(
"BooleanLiteralArgument"
)
if
(
_isRecalled
.
compareAndSet
(
false
,
true
))
{
if
(
_isRecalled
.
compareAndSet
(
false
,
true
))
{
when
(
val
contact
=
target
)
{
when
(
val
contact
=
target
)
{
is
Group
->
{
is
Group
->
{
return
contact
.
recallIn
(
originalMessage
,
delay
)
return
contact
.
recallIn
(
originalMessage
,
millis
)
}
}
is
QQ
->
{
is
QQ
->
{
TODO
()
TODO
()
...
@@ -94,10 +93,33 @@ open class MessageReceipt<C : Contact>(
...
@@ -94,10 +93,33 @@ open class MessageReceipt<C : Contact>(
*
*
* @throws IllegalStateException 当此消息不是群消息时
* @throws IllegalStateException 当此消息不是群消息时
*/
*/
@
UseExperimental
(
MiraiExperimentalAPI
::
class
)
@
MiraiExperimentalAPI
(
"unstable"
)
open
fun
quote
():
MessageChain
{
open
fun
quote
():
MessageChain
{
val
target
=
target
val
target
=
target
check
(
target
is
Group
)
{
"quote is only available for GroupMessage"
}
check
(
target
is
Group
)
{
"quote is only available for GroupMessage"
}
return
this
.
originalMessage
.
quote
(
target
.
botAsMember
)
return
this
.
originalMessage
.
quote
(
target
.
botAsMember
)
}
}
}
\ No newline at end of file
/**
* 引用这条消息并回复. 仅群消息能被引用
*
* @see MessageChain.quote 引用一条消息
*
* @throws IllegalStateException 当此消息不是群消息时
*/
@MiraiExperimentalAPI
(
"unstable"
)
suspend
fun
quoteReply
(
message
:
MessageChain
)
{
target
.
sendMessage
(
this
.
quote
()
+
message
)
}
}
@MiraiExperimentalAPI
(
"unstable"
)
suspend
inline
fun
MessageReceipt
<
out
Contact
>.
quoteReply
(
message
:
Message
)
{
return
this
.
quoteReply
(
message
.
toChain
())
}
@MiraiExperimentalAPI
(
"unstable"
)
suspend
inline
fun
MessageReceipt
<
out
Contact
>.
quoteReply
(
message
:
String
)
{
return
this
.
quoteReply
(
message
.
toMessage
().
toChain
())
}
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