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
c27ee12b
Commit
c27ee12b
authored
Apr 10, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify MessageReceipt
parent
ae1156b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
188 deletions
+42
-188
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt
...roidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt
+0
-89
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
...mmonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
+42
-10
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt
.../jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt
+0
-89
No files found.
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt
deleted
100644 → 0
View file @
ae1156b4
@
file
:
Suppress
(
"unused"
)
package
net.mamoe.mirai.message
import
kotlinx.atomicfu.atomic
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.JavaFriendlyAPI
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.contact.QQ
import
net.mamoe.mirai.message.data.Message
import
net.mamoe.mirai.message.data.OnlineMessageSource
import
net.mamoe.mirai.message.data.QuoteReply
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.unsafeWeakRef
/**
* 发送消息后得到的回执. 可用于撤回.
*
* 此对象持有 [Contact] 的弱引用, [Bot] 离线后将会释放引用, 届时 [target] 将无法访问.
*
* @param source 指代发送出去的消息
* @param target 消息发送对象
*
* @see Group.sendMessage 发送群消息, 返回回执(此对象)
* @see QQ.sendMessage 发送群消息, 返回回执(此对象)
* @see Member.sendMessage 发送临时消息, 返回回执(此对象)
*
* @see MessageReceipt.sourceId 源 id
* @see MessageReceipt.sourceTime 源时间
*/
@Suppress
(
"FunctionName"
)
@OptIn
(
MiraiInternalAPI
::
class
)
actual
open
class
MessageReceipt
<
out
C
:
Contact
>
actual
constructor
(
actual
val
source
:
OnlineMessageSource
.
Outgoing
,
target
:
C
,
private
val
botAsMember
:
Member
?
)
{
init
{
require
(
target
is
Group
||
target
is
QQ
)
{
"target must be either Group or QQ"
}
}
/**
* 发送目标, 为 [Group] 或 [QQ] 或 [Member]
*/
actual
val
target
:
C
by
target
.
unsafeWeakRef
()
/**
* 是否为发送给群的消息的回执
*/
actual
val
isToGroup
:
Boolean
=
botAsMember
!=
null
private
val
_isRecalled
=
atomic
(
false
)
@JavaFriendlyAPI
@JvmName
(
"quoteReply"
)
fun
__quoteReplyBlockingForJava__
(
message
:
Message
):
MessageReceipt
<
C
>
{
return
runBlocking
{
return
@
runBlocking
quoteReply
(
message
)
}
}
@JavaFriendlyAPI
@JvmName
(
"quoteReply"
)
fun
__quoteReplyBlockingForJava__
(
message
:
String
):
MessageReceipt
<
C
>
{
return
runBlocking
{
quoteReply
(
message
)
}
}
@JavaFriendlyAPI
@JvmName
(
"recall"
)
fun
__recallBlockingForJava__
()
{
return
runBlocking
{
return
@
runBlocking
recall
()
}
}
@JavaFriendlyAPI
@JvmName
(
"recall"
)
fun
__recallInBlockingForJava__
(
timeMillis
:
Long
):
Job
{
return
recallIn
(
timeMillis
=
timeMillis
)
}
@JavaFriendlyAPI
@JvmName
(
"quote"
)
fun
__quoteBlockingForJava__
():
QuoteReply
{
return
this
.
quote
()
}
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
View file @
c27ee12b
...
...
@@ -7,17 +7,21 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@
file
:
Suppress
(
"NOTHING_TO_INLINE"
)
@
file
:
Suppress
(
"NOTHING_TO_INLINE"
,
"FunctionName"
,
"unused"
)
package
net.mamoe.mirai.message
import
kotlinx.coroutines.Job
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.JavaFriendlyAPI
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.recallIn
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.internal.runBlocking
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.EmptyCoroutineContext
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmSynthetic
/**
...
...
@@ -35,25 +39,53 @@ import kotlin.jvm.JvmSynthetic
* @see MessageReceipt.sourceId 源 id
* @see MessageReceipt.sourceTime 源时间
*/
expect
open
class
MessageReceipt
<
out
C
:
Contact
>(
source
:
OnlineMessageSource
.
Outgoing
,
target
:
C
,
botAsMember
:
Member
?
)
{
@OptIn
(
MiraiInternalAPI
::
class
)
open
class
MessageReceipt
<
out
C
:
Contact
>(
/**
* 指代发送出去的消息
*/
val
source
:
OnlineMessageSource
.
Outgoing
val
source
:
OnlineMessageSource
.
Outgoing
,
/**
* 发送目标, 为 [Group] 或 [QQ] 或 [Member]
*/
val
target
:
C
val
target
:
C
,
val
botAsMember
:
Member
?
)
{
/**
* 是否为发送给群的消息的回执
*/
val
isToGroup
:
Boolean
val
isToGroup
:
Boolean
=
target
is
Group
@JavaFriendlyAPI
@JvmName
(
"quoteReply"
)
fun
__quoteReplyBlockingForJava__
(
message
:
Message
):
MessageReceipt
<
C
>
{
return
runBlocking
{
return
@
runBlocking
quoteReply
(
message
)
}
}
@JavaFriendlyAPI
@JvmName
(
"quoteReply"
)
fun
__quoteReplyBlockingForJava__
(
message
:
String
):
MessageReceipt
<
C
>
{
return
runBlocking
{
quoteReply
(
message
)
}
}
@JavaFriendlyAPI
@JvmName
(
"recall"
)
fun
__recallBlockingForJava__
()
{
return
runBlocking
{
recall
()
}
}
@JavaFriendlyAPI
@JvmName
(
"recall"
)
fun
__recallInBlockingForJava__
(
timeMillis
:
Long
):
Job
{
return
recallIn
(
timeMillis
=
timeMillis
)
}
@JavaFriendlyAPI
@JvmName
(
"quote"
)
fun
__quoteBlockingForJava__
():
QuoteReply
{
return
this
.
quote
()
}
}
/**
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt
deleted
100644 → 0
View file @
ae1156b4
@
file
:
Suppress
(
"unused"
)
package
net.mamoe.mirai.message
import
kotlinx.atomicfu.atomic
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.JavaFriendlyAPI
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.contact.QQ
import
net.mamoe.mirai.message.data.Message
import
net.mamoe.mirai.message.data.OnlineMessageSource
import
net.mamoe.mirai.message.data.QuoteReply
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.unsafeWeakRef
/**
* 发送消息后得到的回执. 可用于撤回.
*
* 此对象持有 [Contact] 的弱引用, [Bot] 离线后将会释放引用, 届时 [target] 将无法访问.
*
* @param source 指代发送出去的消息
* @param target 消息发送对象
*
* @see Group.sendMessage 发送群消息, 返回回执(此对象)
* @see QQ.sendMessage 发送群消息, 返回回执(此对象)
* @see Member.sendMessage 发送临时消息, 返回回执(此对象)
*
* @see MessageReceipt.sourceId 源 id
* @see MessageReceipt.sourceTime 源时间
*/
@Suppress
(
"FunctionName"
)
@OptIn
(
MiraiInternalAPI
::
class
)
actual
open
class
MessageReceipt
<
out
C
:
Contact
>
actual
constructor
(
actual
val
source
:
OnlineMessageSource
.
Outgoing
,
target
:
C
,
private
val
botAsMember
:
Member
?
)
{
init
{
require
(
target
is
Group
||
target
is
QQ
)
{
"target must be either Group or QQ"
}
}
/**
* 发送目标, 为 [Group] 或 [QQ] 或 [Member]
*/
actual
val
target
:
C
by
target
.
unsafeWeakRef
()
/**
* 是否为发送给群的消息的回执
*/
actual
val
isToGroup
:
Boolean
=
botAsMember
!=
null
private
val
_isRecalled
=
atomic
(
false
)
@JavaFriendlyAPI
@JvmName
(
"quoteReply"
)
fun
__quoteReplyBlockingForJava__
(
message
:
Message
):
MessageReceipt
<
C
>
{
return
runBlocking
{
return
@
runBlocking
quoteReply
(
message
)
}
}
@JavaFriendlyAPI
@JvmName
(
"quoteReply"
)
fun
__quoteReplyBlockingForJava__
(
message
:
String
):
MessageReceipt
<
C
>
{
return
runBlocking
{
quoteReply
(
message
)
}
}
@JavaFriendlyAPI
@JvmName
(
"recall"
)
fun
__recallBlockingForJava__
()
{
return
runBlocking
{
recall
()
}
}
@JavaFriendlyAPI
@JvmName
(
"recall"
)
fun
__recallInBlockingForJava__
(
timeMillis
:
Long
):
Job
{
return
recallIn
(
timeMillis
=
timeMillis
)
}
@JavaFriendlyAPI
@JvmName
(
"quote"
)
fun
__quoteBlockingForJava__
():
QuoteReply
{
return
this
.
quote
()
}
}
\ 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