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
3c25c3df
Commit
3c25c3df
authored
Mar 03, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify calls
parent
9047fd0d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
16 deletions
+30
-16
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt
...in/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
...commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
+0
-13
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
...ommonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
+28
-2
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
3c25c3df
...
...
@@ -152,6 +152,7 @@ internal abstract class QQAndroidBotBase constructor(
getGroup
(
source
.
groupId
).
checkBotPermissionOperator
()
}
println
(
source
.
_miraiContentToString
())
source
.
ensureSequenceIdAvailable
()
network
.
run
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt
View file @
3c25c3df
...
...
@@ -38,7 +38,7 @@ internal class MessageSourceFromServer(
override
val
id
:
Long
get
()
=
(
delegate
.
origSeqs
?.
firstOrNull
()
?:
error
(
"cannot find sequenceId from ImMsgBody.SourceMsg"
)).
toLong
().
shl
(
32
)
or
(
delegate
.
pbReserve
.
loadAs
(
SourceMsg
.
ResvAttr
.
serializer
()).
origUids
!!
.
toInt
()).
toLong
()
.
and
(
0
xFFFFFFFF
)
delegate
.
pbReserve
.
loadAs
(
SourceMsg
.
ResvAttr
.
serializer
()).
origUids
!!
.
and
(
0
xFFFFFFFF
)
override
val
toUin
:
Long
get
()
=
delegate
.
toUin
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
View file @
3c25c3df
...
...
@@ -9,17 +9,12 @@
package
net.mamoe.mirai.message
import
kotlinx.coroutines.Job
import
net.mamoe.mirai.Bot
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.MessageChain
import
net.mamoe.mirai.message.data.MessageSource
import
net.mamoe.mirai.recall
import
net.mamoe.mirai.recallIn
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.unsafeWeakRef
...
...
@@ -41,14 +36,6 @@ class GroupMessage(
inline
fun
Long
.
member
():
Member
=
group
[
this
]
@MiraiExperimentalAPI
suspend
inline
fun
MessageChain
.
recall
()
=
bot
.
recall
(
this
)
suspend
inline
fun
MessageSource
.
recall
()
=
bot
.
recall
(
this
)
inline
fun
MessageSource
.
recallIn
(
delay
:
Long
):
Job
=
bot
.
recallIn
(
this
,
delay
)
@MiraiExperimentalAPI
inline
fun
MessageChain
.
recallIn
(
delay
:
Long
):
Job
=
bot
.
recallIn
(
this
,
delay
)
override
fun
toString
():
String
=
"GroupMessage(group=${group.id}, senderName=$senderName, sender=${sender.id}, permission=${permission.name}, message=$message)"
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt
View file @
3c25c3df
...
...
@@ -22,7 +22,11 @@ import net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.event.subscribingGet
import
net.mamoe.mirai.event.subscribingGetOrNull
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.recall
import
net.mamoe.mirai.recallIn
import
net.mamoe.mirai.utils.*
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.EmptyCoroutineContext
import
kotlin.jvm.JvmName
/**
...
...
@@ -95,6 +99,26 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : Packet, Bot
suspend
inline
fun
MessageChain
.
reply
():
MessageReceipt
<
TSubject
>
=
reply
(
this
)
// endregion
// region 撤回
suspend
inline
fun
MessageChain
.
recall
()
=
bot
.
recall
(
this
)
suspend
inline
fun
MessageSource
.
recall
()
=
bot
.
recall
(
this
)
suspend
inline
fun
QuoteReply
.
recall
()
=
bot
.
recall
(
this
.
source
)
inline
fun
MessageChain
.
recallIn
(
millis
:
Long
,
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
)
=
bot
.
recallIn
(
this
,
millis
,
coroutineContext
)
inline
fun
MessageSource
.
recallIn
(
millis
:
Long
,
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
)
=
bot
.
recallIn
(
this
,
millis
,
coroutineContext
)
inline
fun
QuoteReply
.
recallIn
(
millis
:
Long
,
coroutineContext
:
CoroutineContext
=
EmptyCoroutineContext
)
=
bot
.
recallIn
(
this
.
source
,
millis
,
coroutineContext
)
// endregion
// region 上传图片
suspend
inline
fun
ExternalImage
.
upload
():
Image
=
this
.
upload
(
subject
)
// endregion
...
...
@@ -113,7 +137,8 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : Packet, Bot
* 对于好友消息事件, 这个方法将会给好友 ([subject]) 发送消息
* 对于群消息事件, 这个方法将会给群 ([subject]) 发送消息
*/
suspend
inline
fun
quoteReply
(
message
:
MessageChain
):
MessageReceipt
<
TSubject
>
=
reply
(
this
.
message
.
quote
()
+
message
)
suspend
inline
fun
quoteReply
(
message
:
MessageChain
):
MessageReceipt
<
TSubject
>
=
reply
(
this
.
message
.
quote
()
+
message
)
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
)
...
...
@@ -141,7 +166,8 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : Packet, Bot
*/
fun
QQ
.
at
():
At
=
At
(
this
as
?
Member
?:
error
(
"`QQ.at` can only be used in GroupMessage"
))
fun
At
.
member
():
Member
=
(
this
@MessagePacketBase
as
?
GroupMessage
)
?.
group
?.
get
(
this
.
target
)
?:
error
(
"`At.member` can only be used in GroupMessage"
)
fun
At
.
member
():
Member
=
(
this
@MessagePacketBase
as
?
GroupMessage
)
?.
group
?.
get
(
this
.
target
)
?:
error
(
"`At.member` can only be used in GroupMessage"
)
// endregion
...
...
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