Skip to content

Commit

Permalink
Improve commit 4d4a6ca
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoACE6716 committed Nov 5, 2023
1 parent 4d4a6ca commit b0c0be1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/main/java/snw/kookbc/impl/entity/builder/MessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,17 @@ public PrivateMessage buildPrivateMessage(JsonObject object) {
JsonObject authorObj = get(extra, "author").getAsJsonObject();
User author = client.getStorage().getUser(get(authorObj, "id").getAsString(), authorObj);
long timeStamp = get(object, "msg_timestamp").getAsLong();
final JsonObject quote = get(extra, "quote").getAsJsonObject();
final JsonObject quote;
JsonObject quote1;
try {
quote1 = get(extra, "quote").getAsJsonObject();
} catch (NoSuchElementException e) {
quote1 = null;
}
quote = quote1;
if (quote == null) {
return new PrivateMessageImpl(client, id, author, buildComponent(object), timeStamp, null);
}
final String quoteId = get(quote, "rong_id").getAsString();
Message quoteObject;
Message quoteFromCache = client.getStorage().getMessage(quoteId);
Expand All @@ -112,7 +122,17 @@ public TextChannelMessage buildTextChannelMessage(JsonObject object) {
User author = client.getStorage().getUser(get(authorObj, "id").getAsString(), authorObj);
TextChannel channel = (TextChannel) client.getStorage().getChannel(get(object, "target_id").getAsString());
long timeStamp = get(object, "msg_timestamp").getAsLong();
final JsonObject quote = get(extra, "quote").getAsJsonObject();
final JsonObject quote;
JsonObject quote1;
try {
quote1 = get(extra, "quote").getAsJsonObject();
} catch (NoSuchElementException e) {
quote1 = null;
}
quote = quote1;
if (quote == null) {
return new TextChannelMessageImpl(client, id, author, buildComponent(object), timeStamp, null, channel);
}
final String quoteId = get(quote, "rong_id").getAsString();
Message quoteObject;
Message quoteFromCache = client.getStorage().getMessage(quoteId);
Expand Down

0 comments on commit b0c0be1

Please sign in to comment.