359 lines
12 KiB
Smali
359 lines
12 KiB
Smali
.class public final Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
.super Ljava/lang/Object;
|
|
.source "MessageUnparser.kt"
|
|
|
|
|
|
# static fields
|
|
.field public static final INSTANCE:Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
.field public static final PATTERN_CHANNEL_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
.field public static final PATTERN_CUSTOM_EMOJI:Ljava/util/regex/Pattern;
|
|
|
|
.field public static final PATTERN_ROLE_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
.field public static final PATTERN_USER_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
new-instance v0, Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
invoke-direct {v0}, Lcom/discord/utilities/textprocessing/MessageUnparser;-><init>()V
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUnparser;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
const-string v0, "^<@!?(\\d+)>"
|
|
|
|
invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_USER_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
const-string v0, "^<@&?(\\d+)>"
|
|
|
|
invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_ROLE_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
const-string v0, "^<#?(\\d+)>"
|
|
|
|
invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_CHANNEL_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
const-string v0, "^<(a)?:(\\w+):(\\d+)>"
|
|
|
|
invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_CUSTOM_EMOJI:Ljava/util/regex/Pattern;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final getChannelMentionRule(Ljava/util/Map;)Lcom/discord/simpleast/core/parser/Rule;
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T:",
|
|
"Ljava/lang/Object;",
|
|
"S:",
|
|
"Ljava/lang/Object;",
|
|
">(",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelChannel;",
|
|
">;)",
|
|
"Lcom/discord/simpleast/core/parser/Rule<",
|
|
"TT;",
|
|
"Lcom/discord/simpleast/core/node/Node<",
|
|
"TT;>;TS;>;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Lcom/discord/utilities/textprocessing/MessageUnparser$getChannelMentionRule$1;
|
|
|
|
sget-object v1, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_CHANNEL_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
const-string v2, "PATTERN_CHANNEL_MENTION"
|
|
|
|
invoke-static {v1, v2}, Lw/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {v0, p0, p1, v1}, Lcom/discord/utilities/textprocessing/MessageUnparser$getChannelMentionRule$1;-><init>(Lcom/discord/utilities/textprocessing/MessageUnparser;Ljava/util/Map;Ljava/util/regex/Pattern;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private final getCustomEmojiRule(Lcom/discord/models/domain/emoji/EmojiSet;)Lcom/discord/simpleast/core/parser/Rule;
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T:",
|
|
"Ljava/lang/Object;",
|
|
"S:",
|
|
"Ljava/lang/Object;",
|
|
">(",
|
|
"Lcom/discord/models/domain/emoji/EmojiSet;",
|
|
")",
|
|
"Lcom/discord/simpleast/core/parser/Rule<",
|
|
"TT;",
|
|
"Lcom/discord/simpleast/core/node/Node<",
|
|
"TT;>;TS;>;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Lcom/discord/utilities/textprocessing/MessageUnparser$getCustomEmojiRule$1;
|
|
|
|
sget-object v1, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_CUSTOM_EMOJI:Ljava/util/regex/Pattern;
|
|
|
|
const-string v2, "PATTERN_CUSTOM_EMOJI"
|
|
|
|
invoke-static {v1, v2}, Lw/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {v0, p0, p1, v1}, Lcom/discord/utilities/textprocessing/MessageUnparser$getCustomEmojiRule$1;-><init>(Lcom/discord/utilities/textprocessing/MessageUnparser;Lcom/discord/models/domain/emoji/EmojiSet;Ljava/util/regex/Pattern;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private final getRoleMentionRule(Ljava/util/List;)Lcom/discord/simpleast/core/parser/Rule;
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T:",
|
|
"Ljava/lang/Object;",
|
|
"S:",
|
|
"Ljava/lang/Object;",
|
|
">(",
|
|
"Ljava/util/List<",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelGuildRole;",
|
|
">;)",
|
|
"Lcom/discord/simpleast/core/parser/Rule<",
|
|
"TT;",
|
|
"Lcom/discord/simpleast/core/node/Node<",
|
|
"TT;>;TS;>;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Lcom/discord/utilities/textprocessing/MessageUnparser$getRoleMentionRule$1;
|
|
|
|
sget-object v1, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_ROLE_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
const-string v2, "PATTERN_ROLE_MENTION"
|
|
|
|
invoke-static {v1, v2}, Lw/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {v0, p0, p1, v1}, Lcom/discord/utilities/textprocessing/MessageUnparser$getRoleMentionRule$1;-><init>(Lcom/discord/utilities/textprocessing/MessageUnparser;Ljava/util/List;Ljava/util/regex/Pattern;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private final getUserMentionRule(Ljava/util/Map;)Lcom/discord/simpleast/core/parser/Rule;
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T:",
|
|
"Ljava/lang/Object;",
|
|
"S:",
|
|
"Ljava/lang/Object;",
|
|
">(",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelUser;",
|
|
">;)",
|
|
"Lcom/discord/simpleast/core/parser/Rule<",
|
|
"TT;",
|
|
"Lcom/discord/simpleast/core/node/Node<",
|
|
"TT;>;TS;>;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Lcom/discord/utilities/textprocessing/MessageUnparser$getUserMentionRule$1;
|
|
|
|
sget-object v1, Lcom/discord/utilities/textprocessing/MessageUnparser;->PATTERN_USER_MENTION:Ljava/util/regex/Pattern;
|
|
|
|
const-string v2, "PATTERN_USER_MENTION"
|
|
|
|
invoke-static {v1, v2}, Lw/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {v0, p0, p1, v1}, Lcom/discord/utilities/textprocessing/MessageUnparser$getUserMentionRule$1;-><init>(Lcom/discord/utilities/textprocessing/MessageUnparser;Ljava/util/Map;Ljava/util/regex/Pattern;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public static final unparse(Ljava/lang/String;Lcom/discord/models/domain/ModelGuild;Ljava/util/Map;Ljava/util/Map;Lcom/discord/models/domain/emoji/EmojiSet;)Ljava/lang/CharSequence;
|
|
.locals 7
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/lang/String;",
|
|
"Lcom/discord/models/domain/ModelGuild;",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelChannel;",
|
|
">;",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelUser;",
|
|
">;",
|
|
"Lcom/discord/models/domain/emoji/EmojiSet;",
|
|
")",
|
|
"Ljava/lang/CharSequence;"
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p0, :cond_4
|
|
|
|
if-eqz p2, :cond_3
|
|
|
|
if-eqz p3, :cond_2
|
|
|
|
if-eqz p4, :cond_1
|
|
|
|
new-instance v1, Lcom/discord/simpleast/core/parser/Parser;
|
|
|
|
const/4 v2, 0x0
|
|
|
|
const/4 v3, 0x1
|
|
|
|
invoke-direct {v1, v2, v3, v0}, Lcom/discord/simpleast/core/parser/Parser;-><init>(ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
|
|
|
sget-object v2, Lcom/discord/utilities/textprocessing/MessageUnparser;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
invoke-direct {v2, p3}, Lcom/discord/utilities/textprocessing/MessageUnparser;->getUserMentionRule(Ljava/util/Map;)Lcom/discord/simpleast/core/parser/Rule;
|
|
|
|
move-result-object p3
|
|
|
|
invoke-virtual {v1, p3}, Lcom/discord/simpleast/core/parser/Parser;->addRule(Lcom/discord/simpleast/core/parser/Rule;)Lcom/discord/simpleast/core/parser/Parser;
|
|
|
|
move-result-object p3
|
|
|
|
sget-object v1, Lcom/discord/utilities/textprocessing/MessageUnparser;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
invoke-virtual {p1}, Lcom/discord/models/domain/ModelGuild;->getRoles()Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
sget-object p1, Lw/q/o;->d:Lw/q/o;
|
|
|
|
:goto_0
|
|
invoke-direct {v1, p1}, Lcom/discord/utilities/textprocessing/MessageUnparser;->getRoleMentionRule(Ljava/util/List;)Lcom/discord/simpleast/core/parser/Rule;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p3, p1}, Lcom/discord/simpleast/core/parser/Parser;->addRule(Lcom/discord/simpleast/core/parser/Rule;)Lcom/discord/simpleast/core/parser/Parser;
|
|
|
|
move-result-object p1
|
|
|
|
sget-object p3, Lcom/discord/utilities/textprocessing/MessageUnparser;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
invoke-direct {p3, p2}, Lcom/discord/utilities/textprocessing/MessageUnparser;->getChannelMentionRule(Ljava/util/Map;)Lcom/discord/simpleast/core/parser/Rule;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p1, p2}, Lcom/discord/simpleast/core/parser/Parser;->addRule(Lcom/discord/simpleast/core/parser/Rule;)Lcom/discord/simpleast/core/parser/Parser;
|
|
|
|
move-result-object p1
|
|
|
|
sget-object p2, Lcom/discord/utilities/textprocessing/MessageUnparser;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUnparser;
|
|
|
|
invoke-direct {p2, p4}, Lcom/discord/utilities/textprocessing/MessageUnparser;->getCustomEmojiRule(Lcom/discord/models/domain/emoji/EmojiSet;)Lcom/discord/simpleast/core/parser/Rule;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p1, p2}, Lcom/discord/simpleast/core/parser/Parser;->addRule(Lcom/discord/simpleast/core/parser/Rule;)Lcom/discord/simpleast/core/parser/Parser;
|
|
|
|
move-result-object p1
|
|
|
|
sget-object p2, Le/a/g/a/b/a;->h:Le/a/g/a/b/a;
|
|
|
|
invoke-virtual {p2}, Le/a/g/a/b/a;->f()Lcom/discord/simpleast/core/parser/Rule;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p1, p2}, Lcom/discord/simpleast/core/parser/Parser;->addRule(Lcom/discord/simpleast/core/parser/Rule;)Lcom/discord/simpleast/core/parser/Parser;
|
|
|
|
move-result-object v1
|
|
|
|
const/4 v3, 0x0
|
|
|
|
const/4 v4, 0x0
|
|
|
|
const/4 v5, 0x4
|
|
|
|
const/4 v6, 0x0
|
|
|
|
move-object v2, p0
|
|
|
|
invoke-static/range {v1 .. v6}, Lcom/discord/simpleast/core/parser/Parser;->parse$default(Lcom/discord/simpleast/core/parser/Parser;Ljava/lang/CharSequence;Ljava/lang/Object;Ljava/util/List;ILjava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0, v0}, Lcom/discord/utilities/textprocessing/AstRenderer;->render(Ljava/util/Collection;Ljava/lang/Object;)Lcom/facebook/drawee/span/DraweeSpanStringBuilder;
|
|
|
|
move-result-object p0
|
|
|
|
const-string p1, "AstRenderer.render(parse\u2026sageContent, null), null)"
|
|
|
|
invoke-static {p0, p1}, Lw/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_1
|
|
const-string p0, "emojiSet"
|
|
|
|
invoke-static {p0}, Lw/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_2
|
|
const-string p0, "users"
|
|
|
|
invoke-static {p0}, Lw/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_3
|
|
const-string p0, "channels"
|
|
|
|
invoke-static {p0}, Lw/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_4
|
|
const-string p0, "rawMessageContent"
|
|
|
|
invoke-static {p0}, Lw/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|