mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-01 03:50:18 +08:00
[core] Show specific reason for error 46 while sending message. Close #2127
This commit is contained in:
parent
4abcb7fb4e
commit
573f08955c
@ -563,6 +563,7 @@ public final class net/mamoe/mirai/contact/Platform$Companion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class net/mamoe/mirai/contact/SendMessageFailedException : java/lang/RuntimeException {
|
public class net/mamoe/mirai/contact/SendMessageFailedException : java/lang/RuntimeException {
|
||||||
|
public synthetic fun <init> (Lnet/mamoe/mirai/contact/Contact;Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;Lnet/mamoe/mirai/message/data/Message;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
public final fun getOriginalMessage ()Lnet/mamoe/mirai/message/data/Message;
|
public final fun getOriginalMessage ()Lnet/mamoe/mirai/message/data/Message;
|
||||||
public final fun getReason ()Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public final fun getReason ()Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
public fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||||
@ -572,6 +573,7 @@ public final class net/mamoe/mirai/contact/SendMessageFailedException$Reason : j
|
|||||||
public static final field AT_ALL_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field AT_ALL_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static final field BOT_MUTED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field BOT_MUTED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static final field GROUP_CHAT_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field GROUP_CHAT_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
|
public static final field LIMITED_MESSAGING Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static final field MESSAGE_TOO_LARGE Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field MESSAGE_TOO_LARGE Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static fun valueOf (Ljava/lang/String;)Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static fun valueOf (Ljava/lang/String;)Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static fun values ()[Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static fun values ()[Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
|
@ -563,6 +563,7 @@ public final class net/mamoe/mirai/contact/Platform$Companion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class net/mamoe/mirai/contact/SendMessageFailedException : java/lang/RuntimeException {
|
public class net/mamoe/mirai/contact/SendMessageFailedException : java/lang/RuntimeException {
|
||||||
|
public synthetic fun <init> (Lnet/mamoe/mirai/contact/Contact;Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;Lnet/mamoe/mirai/message/data/Message;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||||
public final fun getOriginalMessage ()Lnet/mamoe/mirai/message/data/Message;
|
public final fun getOriginalMessage ()Lnet/mamoe/mirai/message/data/Message;
|
||||||
public final fun getReason ()Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public final fun getReason ()Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
public fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||||
@ -572,6 +573,7 @@ public final class net/mamoe/mirai/contact/SendMessageFailedException$Reason : j
|
|||||||
public static final field AT_ALL_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field AT_ALL_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static final field BOT_MUTED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field BOT_MUTED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static final field GROUP_CHAT_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field GROUP_CHAT_LIMITED Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
|
public static final field LIMITED_MESSAGING Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static final field MESSAGE_TOO_LARGE Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static final field MESSAGE_TOO_LARGE Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static fun valueOf (Ljava/lang/String;)Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static fun valueOf (Ljava/lang/String;)Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
public static fun values ()[Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
public static fun values ()[Lnet/mamoe/mirai/contact/SendMessageFailedException$Reason;
|
||||||
|
@ -74,8 +74,12 @@ public open class SendMessageFailedException @MiraiInternalApi constructor(
|
|||||||
public open val target: Contact,
|
public open val target: Contact,
|
||||||
public val reason: Reason,
|
public val reason: Reason,
|
||||||
public val originalMessage: Message,
|
public val originalMessage: Message,
|
||||||
|
/**
|
||||||
|
* @since 2.14
|
||||||
|
*/
|
||||||
|
tips: String? = null,
|
||||||
) : RuntimeException(
|
) : RuntimeException(
|
||||||
"Failed sending message to $target, reason=$reason"
|
"Failed sending message to $target, reason=$reason. Tips: $tips"
|
||||||
) {
|
) {
|
||||||
public enum class Reason {
|
public enum class Reason {
|
||||||
/**
|
/**
|
||||||
@ -98,5 +102,12 @@ public open class SendMessageFailedException @MiraiInternalApi constructor(
|
|||||||
* @since 2.11
|
* @since 2.11
|
||||||
*/
|
*/
|
||||||
AT_ALL_LIMITED,
|
AT_ALL_LIMITED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 被服务器限制发送消息, 属于冻结的一种
|
||||||
|
*
|
||||||
|
* @since 2.14
|
||||||
|
*/
|
||||||
|
LIMITED_MESSAGING,
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -145,6 +145,13 @@ internal class GeneralMessageSenderProtocol : MessageProtocol(PRIORITY_GENERAL_S
|
|||||||
SendMessageFailedException.Reason.GROUP_CHAT_LIMITED,
|
SendMessageFailedException.Reason.GROUP_CHAT_LIMITED,
|
||||||
originalMessage
|
originalMessage
|
||||||
)
|
)
|
||||||
|
// #2127
|
||||||
|
46 -> throw SendMessageFailedException(
|
||||||
|
contact,
|
||||||
|
SendMessageFailedException.Reason.LIMITED_MESSAGING,
|
||||||
|
originalMessage,
|
||||||
|
tips = "问题原因可能是账号被多次举报或被服务器认为不安全. 可尝试访问 https://accounts.qq.com/safe/message/unlock?lock_info=5_5 解冻."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check(resp is MessageSvcPbSendMsg.Response.SUCCESS) {
|
check(resp is MessageSvcPbSendMsg.Response.SUCCESS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user