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
56fc3aa8
Commit
56fc3aa8
authored
Apr 25, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checks for empty message being sent
parent
364ffc33
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
11 additions
and
0 deletions
+11
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/FriendImpl.kt
...in/kotlin/net/mamoe/mirai/qqandroid/contact/FriendImpl.kt
+2
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
...ain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt
...in/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt
+3
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
.../src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
+1
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Friend.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/contact/Friend.kt
+1
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
...re/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
+1
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
...e/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
+1
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/User.kt
...ore/src/commonMain/kotlin/net.mamoe.mirai/contact/User.kt
+1
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/FriendImpl.kt
View file @
56fc3aa8
...
...
@@ -25,6 +25,7 @@ import net.mamoe.mirai.event.events.ImageUploadEvent
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Message
import
net.mamoe.mirai.message.data.OfflineFriendImage
import
net.mamoe.mirai.message.data.isContentNotEmpty
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.network.highway.postImage
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x352
...
...
@@ -72,6 +73,7 @@ internal class FriendImpl(
@JvmSynthetic
@Suppress
(
"DuplicatedCode"
)
override
suspend
fun
sendMessage
(
message
:
Message
):
MessageReceipt
<
Friend
>
{
require
(
message
.
isContentNotEmpty
())
{
"message is empty"
}
return
sendMessageImpl
(
this
,
message
).
also
{
logMessageSent
(
message
)
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
View file @
56fc3aa8
...
...
@@ -275,6 +275,7 @@ internal class GroupImpl(
@OptIn
(
MiraiExperimentalAPI
::
class
,
LowLevelAPI
::
class
)
@JvmSynthetic
override
suspend
fun
sendMessage
(
message
:
Message
):
MessageReceipt
<
Group
>
{
require
(
message
.
isContentNotEmpty
())
{
"message is empty"
}
check
(!
isBotMuted
)
{
throw
BotIsBeingMutedException
(
this
)
}
return
sendMessageImpl
(
message
,
false
).
also
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt
View file @
56fc3aa8
...
...
@@ -25,6 +25,7 @@ import net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Message
import
net.mamoe.mirai.message.data.OfflineFriendImage
import
net.mamoe.mirai.message.data.asMessageChain
import
net.mamoe.mirai.message.data.isContentNotEmpty
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.message.MessageSourceToTempImpl
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.StTroopMemberInfo
...
...
@@ -54,6 +55,8 @@ internal class MemberImpl constructor(
@JvmSynthetic
override
suspend
fun
sendMessage
(
message
:
Message
):
MessageReceipt
<
Member
>
{
require
(
message
.
isContentNotEmpty
())
{
"message is empty"
}
return
(
this
.
asFriendOrNull
()
?.
sendMessageImpl
(
this
,
message
)
?:
sendMessageImpl
(
message
))
.
also
{
logMessageSent
(
message
)
}
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
View file @
56fc3aa8
...
...
@@ -63,6 +63,7 @@ abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI(), ContactOrBot
* @throws EventCancelledException 当发送消息事件被取消时抛出
* @throws BotIsBeingMutedException 发送群消息时若 [Bot] 被禁言抛出
* @throws MessageTooLargeException 当消息过长时抛出
* @throws IllegalArgumentException 当消息内容为空时抛出 (详见 [Message.isContentEmpty])
*
* @return 消息回执. 可 [引用回复][MessageReceipt.quote](仅群聊)或 [撤回][MessageReceipt.recall] 这条消息.
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Friend.kt
View file @
56fc3aa8
...
...
@@ -63,6 +63,7 @@ abstract class Friend : QQ(), CoroutineScope {
* @throws EventCancelledException 当发送消息事件被取消时抛出
* @throws BotIsBeingMutedException 发送群消息时若 [Bot] 被禁言抛出
* @throws MessageTooLargeException 当消息过长时抛出
* @throws IllegalArgumentException 当消息内容为空时抛出 (详见 [Message.isContentEmpty])
*
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
View file @
56fc3aa8
...
...
@@ -145,6 +145,7 @@ abstract class Group : Contact(), CoroutineScope {
* @throws EventCancelledException 当发送消息事件被取消时抛出
* @throws BotIsBeingMutedException 发送群消息时若 [Bot] 被禁言抛出
* @throws MessageTooLargeException 当消息过长时抛出
* @throws IllegalArgumentException 当消息内容为空时抛出 (详见 [Message.isContentEmpty])
*
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt
View file @
56fc3aa8
...
...
@@ -139,6 +139,7 @@ abstract class Member : MemberJavaFriendlyAPI() {
* @throws EventCancelledException 当发送消息事件被取消时抛出
* @throws BotIsBeingMutedException 发送群消息时若 [Bot] 被禁言抛出
* @throws MessageTooLargeException 当消息过长时抛出
* @throws IllegalArgumentException 当消息内容为空时抛出 (详见 [Message.isContentEmpty])
*
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/User.kt
View file @
56fc3aa8
...
...
@@ -64,6 +64,7 @@ abstract class User : Contact(), CoroutineScope {
* @throws EventCancelledException 当发送消息事件被取消时抛出
* @throws BotIsBeingMutedException 发送群消息时若 [Bot] 被禁言抛出
* @throws MessageTooLargeException 当消息过长时抛出
* @throws IllegalArgumentException 当消息内容为空时抛出 (详见 [Message.isContentEmpty])
*
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/
...
...
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