mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-15 05:00:10 +08:00
Throw specific SendMessageFailedException
when reaching group chat limit, close #1220
This commit is contained in:
parent
a989ea9db1
commit
74fc5a5037
@ -539,6 +539,7 @@ public class net/mamoe/mirai/contact/SendMessageFailedException : java/lang/Runt
|
|||||||
|
|
||||||
public final class net/mamoe/mirai/contact/SendMessageFailedException$Reason : java/lang/Enum {
|
public final class net/mamoe/mirai/contact/SendMessageFailedException$Reason : java/lang/Enum {
|
||||||
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 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;
|
||||||
|
@ -539,6 +539,7 @@ public class net/mamoe/mirai/contact/SendMessageFailedException : java/lang/Runt
|
|||||||
|
|
||||||
public final class net/mamoe/mirai/contact/SendMessageFailedException$Reason : java/lang/Enum {
|
public final class net/mamoe/mirai/contact/SendMessageFailedException$Reason : java/lang/Enum {
|
||||||
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 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;
|
||||||
|
@ -85,5 +85,10 @@ public open class SendMessageFailedException @MiraiInternalApi constructor(
|
|||||||
* 机器人被禁言
|
* 机器人被禁言
|
||||||
*/
|
*/
|
||||||
BOT_MUTED,
|
BOT_MUTED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 达到群每分钟发言次数限制
|
||||||
|
*/
|
||||||
|
GROUP_CHAT_LIMITED,
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -174,6 +174,11 @@ internal abstract class SendMessageHandler<C : Contact> {
|
|||||||
when (resp.resultType) {
|
when (resp.resultType) {
|
||||||
120 -> if (contact is Group) throw BotIsBeingMutedException(contact, originalMessage)
|
120 -> if (contact is Group) throw BotIsBeingMutedException(contact, originalMessage)
|
||||||
121 -> if (AtAll in finalMessage) throw IllegalStateException("Send message to $contact failed, reached maximum AtAll times limit.")
|
121 -> if (AtAll in finalMessage) throw IllegalStateException("Send message to $contact failed, reached maximum AtAll times limit.")
|
||||||
|
299 -> if (contact is Group) throw SendMessageFailedException(
|
||||||
|
contact,
|
||||||
|
SendMessageFailedException.Reason.GROUP_CHAT_LIMITED,
|
||||||
|
originalMessage
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check(resp is MessageSvcPbSendMsg.Response.SUCCESS) {
|
check(resp is MessageSvcPbSendMsg.Response.SUCCESS) {
|
||||||
|
Loading…
Reference in New Issue
Block a user