Skip to content

Commit

Permalink
feat: 检查消息类型时额外判断TemplateMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
huanmeng-qwq committed Nov 12, 2024
1 parent 6bee341 commit b2b5ce6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/snw/kookbc/impl/message/MessageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ protected final void checkCompatibleComponentType(BaseComponent newIncoming) {
if (this.component == null) {
return; // we don't know, let HTTP API check
}
final boolean compatible = isCompatibleComponentType(this.component, newIncoming);
boolean compatible;
if (newIncoming instanceof TemplateMessage) {
int oldType = (int) MessageBuilder.serialize(this.component)[0];
compatible = ((TemplateMessage) newIncoming).getType() == oldType;
} else {
compatible = isCompatibleComponentType(this.component, newIncoming);
}
if (!compatible) {
throw new IllegalArgumentException("Incompatible component type, tried updating from "
+ this.component.getClass() + " to " + newIncoming.getClass());
Expand Down

0 comments on commit b2b5ce6

Please sign in to comment.