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
5f141cdb
Commit
5f141cdb
authored
Feb 23, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Supports friend message quote reply
parent
17aff7d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
17 deletions
+55
-17
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceFromMsg.kt
...net/mamoe/mirai/qqandroid/message/MessageSourceFromMsg.kt
+45
-5
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
...commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
+0
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
...ommonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
+9
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt
...monMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt
+1
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceFromMsg.kt
View file @
5f141cdb
...
...
@@ -53,11 +53,52 @@ internal inline class MessageSourceFromMsg(
// override val sourceMessage: MessageChain get() = delegate.toMessageChain()
override
val
senderId
:
Long
get
()
=
delegate
.
msgHead
.
fromUin
override
val
groupId
:
Long
get
()
=
delegate
.
msgHead
.
groupInfo
!!
.
groupCode
override
val
groupId
:
Long
get
()
=
delegate
.
msgHead
.
groupInfo
?.
groupCode
?:
0
fun
toJceData
():
ImMsgBody
.
SourceMsg
{
return
if
(
groupId
==
0L
)
{
toJceDataImplForFriend
()
}
else
toJceDataImplForGroup
()
}
private
fun
toJceDataImplForFriend
():
ImMsgBody
.
SourceMsg
{
return
ImMsgBody
.
SourceMsg
(
origSeqs
=
listOf
(
delegate
.
msgHead
.
msgSeq
),
senderUin
=
delegate
.
msgHead
.
fromUin
,
toUin
=
delegate
.
msgHead
.
toUin
,
flag
=
1
,
elems
=
delegate
.
msgBody
.
richText
.
elems
,
type
=
0
,
time
=
delegate
.
msgHead
.
msgTime
,
pbReserve
=
SourceMsg
.
ResvAttr
(
origUids
=
messageRandom
.
toLong
()
and
0
xffFFffFF
).
toByteArray
(
SourceMsg
.
ResvAttr
.
serializer
()),
srcMsg
=
MsgComm
.
Msg
(
msgHead
=
MsgComm
.
MsgHead
(
fromUin
=
delegate
.
msgHead
.
fromUin
,
// qq
toUin
=
delegate
.
msgHead
.
toUin
,
// group
msgType
=
delegate
.
msgHead
.
msgType
,
// 82?
c2cCmd
=
delegate
.
msgHead
.
c2cCmd
,
msgSeq
=
delegate
.
msgHead
.
msgSeq
,
msgTime
=
delegate
.
msgHead
.
msgTime
,
msgUid
=
messageRandom
.
toLong
()
and
0
xffFFffFF
,
// ok
// groupInfo = MsgComm.GroupInfo(groupCode = delegate.msgHead.groupInfo.groupCode),
isSrcMsg
=
true
),
msgBody
=
ImMsgBody
.
MsgBody
(
richText
=
ImMsgBody
.
RichText
(
elems
=
delegate
.
msgBody
.
richText
.
elems
.
also
{
if
(
it
.
last
().
elemFlags2
==
null
)
it
.
add
(
ImMsgBody
.
Elem
(
elemFlags2
=
ImMsgBody
.
ElemFlags2
()))
}
)
)
).
toByteArray
(
MsgComm
.
Msg
.
serializer
())
)
}
private
fun
toJceDataImplForGroup
():
ImMsgBody
.
SourceMsg
{
val
groupUin
=
Group
.
calculateGroupUinByGroupCode
(
delegate
.
msgHead
.
groupInfo
!!
.
groupCode
)
val
groupUin
=
Group
.
calculateGroupUinByGroupCode
(
groupId
)
return
ImMsgBody
.
SourceMsg
(
origSeqs
=
listOf
(
delegate
.
msgHead
.
msgSeq
),
...
...
@@ -78,9 +119,8 @@ internal inline class MessageSourceFromMsg(
c2cCmd
=
delegate
.
msgHead
.
c2cCmd
,
msgSeq
=
delegate
.
msgHead
.
msgSeq
,
msgTime
=
delegate
.
msgHead
.
msgTime
,
msgUid
=
messageRandom
.
toLong
()
and
0
xffFFffFF
,
// ok
groupInfo
=
MsgComm
.
GroupInfo
(
groupCode
=
delegate
.
msgHead
.
groupInfo
.
groupCode
),
msgUid
=
messageRandom
.
toLong
()
and
0
xffFFffFF
,
// ok
groupInfo
=
MsgComm
.
GroupInfo
(
groupCode
=
groupId
),
isSrcMsg
=
true
),
msgBody
=
ImMsgBody
.
MsgBody
(
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
View file @
5f141cdb
...
...
@@ -15,7 +15,6 @@ import net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.contact.MemberPermission
import
net.mamoe.mirai.event.Event
import
net.mamoe.mirai.message.data.Message
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.message.data.MessageSource
import
net.mamoe.mirai.recall
...
...
@@ -23,7 +22,6 @@ import net.mamoe.mirai.recallIn
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.unsafeWeakRef
import
kotlin.jvm.JvmName
@Suppress
(
"unused"
,
"NOTHING_TO_INLINE"
)
class
GroupMessage
(
...
...
@@ -43,15 +41,6 @@ class GroupMessage(
inline
fun
Long
.
member
():
Member
=
group
[
this
]
@JvmName
(
"reply2"
)
suspend
inline
fun
String
.
quoteReply
():
MessageReceipt
<
Group
>
=
quoteReply
(
this
)
@JvmName
(
"reply2"
)
suspend
inline
fun
Message
.
quoteReply
():
MessageReceipt
<
Group
>
=
quoteReply
(
this
)
@JvmName
(
"reply2"
)
suspend
inline
fun
MessageChain
.
quoteReply
():
MessageReceipt
<
Group
>
=
quoteReply
(
this
)
@MiraiExperimentalAPI
suspend
inline
fun
MessageChain
.
recall
()
=
bot
.
recall
(
this
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
View file @
5f141cdb
...
...
@@ -114,6 +114,15 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : Packet, Bot
suspend
inline
fun
quoteReply
(
message
:
Message
):
MessageReceipt
<
TSubject
>
=
reply
(
this
.
message
.
quote
()
+
message
)
suspend
inline
fun
quoteReply
(
plain
:
String
):
MessageReceipt
<
TSubject
>
=
reply
(
this
.
message
.
quote
()
+
plain
)
@JvmName
(
"reply2"
)
suspend
inline
fun
String
.
quoteReply
():
MessageReceipt
<
TSubject
>
=
quoteReply
(
this
)
@JvmName
(
"reply2"
)
suspend
inline
fun
Message
.
quoteReply
():
MessageReceipt
<
TSubject
>
=
quoteReply
(
this
)
@JvmName
(
"reply2"
)
suspend
inline
fun
MessageChain
.
quoteReply
():
MessageReceipt
<
TSubject
>
=
quoteReply
(
this
)
/**
* 引用这个消息. 当且仅当消息为群消息时可用. 否则将会抛出 [IllegalArgumentException]
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt
View file @
5f141cdb
...
...
@@ -37,7 +37,7 @@ class QuoteReply @MiraiInternalAPI constructor(val source: MessageSource) : Mess
fun
MessageChain
.
quote
(
sender
:
QQ
):
MessageChain
{
this
.
firstOrNull
<
MessageSource
>()
?.
let
{
return
if
(
it
.
groupId
==
0L
)
{
QuoteReply
(
it
)
+
" "
// required
QuoteReply
(
it
)
.
toChain
()
// required
}
else
{
check
(
sender
is
Member
)
{
"sender must be Member to quote a GroupMessage"
}
QuoteReply
(
it
)
+
sender
.
at
()
+
" "
// required
...
...
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