608 lines
14 KiB
Smali
608 lines
14 KiB
Smali
.class public final Lcom/discord/utilities/textprocessing/MessageUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "MessageUtils.kt"
|
|
|
|
|
|
# static fields
|
|
.field public static final INSTANCE:Lcom/discord/utilities/textprocessing/MessageUtils;
|
|
|
|
.field public static final WELCOME_MESSAGES:[I
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
new-instance v0, Lcom/discord/utilities/textprocessing/MessageUtils;
|
|
|
|
invoke-direct {v0}, Lcom/discord/utilities/textprocessing/MessageUtils;-><init>()V
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUtils;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUtils;
|
|
|
|
const/16 v0, 0xd
|
|
|
|
new-array v0, v0, [I
|
|
|
|
fill-array-data v0, :array_0
|
|
|
|
sput-object v0, Lcom/discord/utilities/textprocessing/MessageUtils;->WELCOME_MESSAGES:[I
|
|
|
|
return-void
|
|
|
|
nop
|
|
|
|
:array_0
|
|
.array-data 4
|
|
0x7f1213bf
|
|
0x7f1213c0
|
|
0x7f1213c1
|
|
0x7f1213c2
|
|
0x7f1213c3
|
|
0x7f1213c4
|
|
0x7f1213c5
|
|
0x7f1213c6
|
|
0x7f1213c7
|
|
0x7f1213c8 # 1.9417E38f
|
|
0x7f1213c9
|
|
0x7f1213ca
|
|
0x7f1213cb
|
|
.end array-data
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final cleanEmojisInQuotedText(Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 2
|
|
|
|
new-instance v0, Lkotlin/text/Regex;
|
|
|
|
const-string v1, "<(a)?:([a-zA-Z_0-9]+):(\\d+)>"
|
|
|
|
invoke-direct {v0, v1}, Lkotlin/text/Regex;-><init>(Ljava/lang/String;)V
|
|
|
|
new-instance v1, Lcom/discord/utilities/textprocessing/MessageUtils$cleanEmojisInQuotedText$1;
|
|
|
|
invoke-direct {v1, p1}, Lcom/discord/utilities/textprocessing/MessageUtils$cleanEmojisInQuotedText$1;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v0, p1, v1}, Lkotlin/text/Regex;->replace(Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method private final cleanTextOfQuotes(Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 10
|
|
|
|
const/4 v0, 0x1
|
|
|
|
new-array v1, v0, [C
|
|
|
|
const/4 v2, 0x0
|
|
|
|
const/16 v3, 0xa
|
|
|
|
aput-char v3, v1, v2
|
|
|
|
const/4 v3, 0x6
|
|
|
|
invoke-static {p1, v1, v2, v2, v3}, Ly/a0/u;->split$default(Ljava/lang/CharSequence;[CZII)Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
new-instance v1, Ljava/util/ArrayList;
|
|
|
|
invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V
|
|
|
|
invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:cond_0
|
|
:goto_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v3
|
|
|
|
move-object v4, v3
|
|
|
|
check-cast v4, Ljava/lang/String;
|
|
|
|
const/4 v5, 0x2
|
|
|
|
const-string v6, "> "
|
|
|
|
invoke-static {v4, v6, v2, v5}, Ly/a0/p;->startsWith$default(Ljava/lang/String;Ljava/lang/String;ZI)Z
|
|
|
|
move-result v4
|
|
|
|
xor-int/2addr v4, v0
|
|
|
|
if-eqz v4, :cond_0
|
|
|
|
invoke-interface {v1, v3}, Ljava/util/Collection;->add(Ljava/lang/Object;)Z
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
invoke-interface {v1}, Ljava/util/List;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_1
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v3
|
|
|
|
const/4 v4, -0x1
|
|
|
|
if-eqz v3, :cond_3
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v3
|
|
|
|
check-cast v3, Ljava/lang/String;
|
|
|
|
invoke-static {v3}, Ly/a0/p;->isBlank(Ljava/lang/CharSequence;)Z
|
|
|
|
move-result v3
|
|
|
|
xor-int/2addr v3, v0
|
|
|
|
if-eqz v3, :cond_2
|
|
|
|
goto :goto_2
|
|
|
|
:cond_2
|
|
add-int/lit8 v2, v2, 0x1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_3
|
|
const/4 v2, -0x1
|
|
|
|
:goto_2
|
|
if-ne v2, v4, :cond_4
|
|
|
|
const/4 p1, 0x0
|
|
|
|
return-object p1
|
|
|
|
:cond_4
|
|
invoke-interface {v1}, Ljava/util/List;->size()I
|
|
|
|
move-result p1
|
|
|
|
invoke-static {v2, p1}, Ly/x/f;->until(II)Lkotlin/ranges/IntRange;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-static {v1, p1}, Ly/q/l;->slice(Ljava/util/List;Lkotlin/ranges/IntRange;)Ljava/util/List;
|
|
|
|
move-result-object v2
|
|
|
|
const/4 v4, 0x0
|
|
|
|
const/4 v5, 0x0
|
|
|
|
const/4 v6, 0x0
|
|
|
|
const/4 v7, 0x0
|
|
|
|
const/4 v8, 0x0
|
|
|
|
const/16 v9, 0x3e
|
|
|
|
const-string v3, "\n"
|
|
|
|
invoke-static/range {v2 .. v9}, Ly/q/l;->joinToString$default(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;I)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method private final formatTextAsQuote(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 11
|
|
|
|
const-string v0, "\n"
|
|
|
|
filled-new-array {v0}, [Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
const/4 v2, 0x6
|
|
|
|
invoke-static {p1, v0, v1, v1, v2}, Ly/a0/u;->split$default(Ljava/lang/CharSequence;[Ljava/lang/String;ZII)Ljava/util/List;
|
|
|
|
move-result-object v3
|
|
|
|
sget-object v9, Lcom/discord/utilities/textprocessing/MessageUtils$formatTextAsQuote$formattedText$1;->INSTANCE:Lcom/discord/utilities/textprocessing/MessageUtils$formatTextAsQuote$formattedText$1;
|
|
|
|
const-string v4, ""
|
|
|
|
const/4 v5, 0x0
|
|
|
|
const/4 v6, 0x0
|
|
|
|
const/4 v7, 0x0
|
|
|
|
const/4 v8, 0x0
|
|
|
|
const/16 v10, 0x1e
|
|
|
|
invoke-static/range {v3 .. v10}, Ly/q/l;->joinToString$default(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;I)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
invoke-static {p1, p2}, Lf/e/b/a/a;->a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
:cond_0
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public static final getNickOrUsernames(Lcom/discord/models/domain/ModelMessage;Lcom/discord/models/domain/ModelChannel;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Lcom/discord/models/domain/ModelMessage;",
|
|
"Lcom/discord/models/domain/ModelChannel;",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelGuildMember$Computed;",
|
|
">;",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelChannel$RecipientNick;",
|
|
">;)",
|
|
"Ljava/util/Map<",
|
|
"Ljava/lang/Long;",
|
|
"Ljava/lang/String;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p0, :cond_2
|
|
|
|
if-eqz p2, :cond_1
|
|
|
|
if-eqz p3, :cond_0
|
|
|
|
invoke-virtual {p0}, Lcom/discord/models/domain/ModelMessage;->getMentions()Ljava/util/List;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "message.mentions"
|
|
|
|
invoke-static {v0, v1}, Ly/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {p0}, Lcom/discord/models/domain/ModelMessage;->getAuthor()Lcom/discord/models/domain/ModelUser;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {v0, p0}, Ly/q/l;->plus(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0, p1, p2, p3}, Lcom/discord/utilities/channel/ChannelUtils;->getNickOrUsernames(Ljava/lang/Iterable;Lcom/discord/models/domain/ModelChannel;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
|
|
:cond_0
|
|
const-string p0, "nicks"
|
|
|
|
invoke-static {p0}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p0, "channelMembers"
|
|
|
|
invoke-static {p0}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_2
|
|
const-string p0, "message"
|
|
|
|
invoke-static {p0}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public static synthetic getNickOrUsernames$default(Lcom/discord/models/domain/ModelMessage;Lcom/discord/models/domain/ModelChannel;Ljava/util/Map;Ljava/util/Map;ILjava/lang/Object;)Ljava/util/Map;
|
|
.locals 0
|
|
|
|
and-int/lit8 p4, p4, 0x8
|
|
|
|
if-eqz p4, :cond_0
|
|
|
|
invoke-static {}, Ly/q/l;->emptyMap()Ljava/util/Map;
|
|
|
|
move-result-object p3
|
|
|
|
:cond_0
|
|
invoke-static {p0, p1, p2, p3}, Lcom/discord/utilities/textprocessing/MessageUtils;->getNickOrUsernames(Lcom/discord/models/domain/ModelMessage;Lcom/discord/models/domain/ModelChannel;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static final getSystemMessageUserJoin(Landroid/content/Context;J)I
|
|
.locals 3
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p0, :cond_4
|
|
|
|
sget v1, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/16 v2, 0x18
|
|
|
|
if-lt v1, v2, :cond_0
|
|
|
|
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
|
|
|
|
move-result-object p0
|
|
|
|
if-eqz p0, :cond_1
|
|
|
|
invoke-virtual {p0}, Landroid/content/res/Resources;->getConfiguration()Landroid/content/res/Configuration;
|
|
|
|
move-result-object p0
|
|
|
|
if-eqz p0, :cond_1
|
|
|
|
invoke-virtual {p0}, Landroid/content/res/Configuration;->getLocales()Landroid/os/LocaleList;
|
|
|
|
move-result-object p0
|
|
|
|
if-eqz p0, :cond_1
|
|
|
|
const/4 v1, 0x0
|
|
|
|
invoke-virtual {p0, v1}, Landroid/os/LocaleList;->get(I)Ljava/util/Locale;
|
|
|
|
move-result-object p0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
|
|
|
|
move-result-object p0
|
|
|
|
if-eqz p0, :cond_1
|
|
|
|
invoke-virtual {p0}, Landroid/content/res/Resources;->getConfiguration()Landroid/content/res/Configuration;
|
|
|
|
move-result-object p0
|
|
|
|
if-eqz p0, :cond_1
|
|
|
|
iget-object p0, p0, Landroid/content/res/Configuration;->locale:Ljava/util/Locale;
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
move-object p0, v0
|
|
|
|
:goto_0
|
|
new-instance v1, Ljava/util/Locale;
|
|
|
|
const-string v2, "en"
|
|
|
|
invoke-direct {v1, v2}, Ljava/util/Locale;-><init>(Ljava/lang/String;)V
|
|
|
|
if-eqz p0, :cond_2
|
|
|
|
invoke-virtual {p0}, Ljava/util/Locale;->getLanguage()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
:cond_2
|
|
invoke-virtual {v1}, Ljava/util/Locale;->getLanguage()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {v0, p0}, Ly/u/b/j;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z
|
|
|
|
move-result p0
|
|
|
|
xor-int/lit8 p0, p0, 0x1
|
|
|
|
if-eqz p0, :cond_3
|
|
|
|
const-wide/16 p0, 0x0
|
|
|
|
goto :goto_1
|
|
|
|
:cond_3
|
|
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0}, Lcom/discord/utilities/time/TimeUtils;->parseSnowflake(Ljava/lang/Long;)J
|
|
|
|
move-result-wide p0
|
|
|
|
sget-object p2, Lcom/discord/utilities/textprocessing/MessageUtils;->WELCOME_MESSAGES:[I
|
|
|
|
array-length p2, p2
|
|
|
|
int-to-long v0, p2
|
|
|
|
rem-long/2addr p0, v0
|
|
|
|
:goto_1
|
|
sget-object p2, Lcom/discord/utilities/textprocessing/MessageUtils;->WELCOME_MESSAGES:[I
|
|
|
|
long-to-int p1, p0
|
|
|
|
aget p0, p2, p1
|
|
|
|
return p0
|
|
|
|
:cond_4
|
|
const-string p0, "context"
|
|
|
|
invoke-static {p0}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final createQuotedText(Lcom/discord/models/domain/ModelMessage;Lcom/discord/models/domain/ModelChannel;)Ljava/lang/String;
|
|
.locals 3
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_3
|
|
|
|
if-eqz p2, :cond_2
|
|
|
|
invoke-virtual {p1}, Lcom/discord/models/domain/ModelMessage;->getContent()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "message.content"
|
|
|
|
invoke-static {v1, v2}, Ly/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p0, v1}, Lcom/discord/utilities/textprocessing/MessageUtils;->cleanTextOfQuotes(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
if-eqz v1, :cond_1
|
|
|
|
invoke-direct {p0, v1}, Lcom/discord/utilities/textprocessing/MessageUtils;->cleanEmojisInQuotedText(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {p2}, Lcom/discord/models/domain/ModelChannel;->isDM()Z
|
|
|
|
move-result p2
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/16 p2, 0x40
|
|
|
|
invoke-static {p2}, Lf/e/b/a/a;->a(C)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p1}, Lcom/discord/models/domain/ModelMessage;->getAuthor()Lcom/discord/models/domain/ModelUser;
|
|
|
|
move-result-object p1
|
|
|
|
const-string v0, "message.author"
|
|
|
|
invoke-static {p1, v0}, Ly/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {p1}, Lcom/discord/models/domain/ModelUser;->getUserNameWithDiscriminator()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const/16 p1, 0x20
|
|
|
|
invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
:goto_0
|
|
invoke-direct {p0, v1, v0}, Lcom/discord/utilities/textprocessing/MessageUtils;->formatTextAsQuote(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
|
|
:cond_1
|
|
return-object v0
|
|
|
|
:cond_2
|
|
const-string p1, "channel"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_3
|
|
const-string p1, "message"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public final isContentQuotable(Lcom/discord/models/domain/ModelMessage;)Z
|
|
.locals 1
|
|
|
|
if-eqz p1, :cond_2
|
|
|
|
invoke-virtual {p1}, Lcom/discord/models/domain/ModelMessage;->getContent()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-nez p1, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-direct {p0, p1}, Lcom/discord/utilities/textprocessing/MessageUtils;->cleanTextOfQuotes(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
const/4 v0, 0x1
|
|
|
|
:cond_1
|
|
:goto_0
|
|
return v0
|
|
|
|
:cond_2
|
|
const-string p1, "message"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
const/4 p1, 0x0
|
|
|
|
throw p1
|
|
.end method
|