49 lines
2 KiB
Java
49 lines
2 KiB
Java
package com.discord.utilities.textprocessing;
|
|
|
|
import c.d.b.a.a;
|
|
import com.discord.models.user.User;
|
|
import com.discord.simpleast.core.node.Node;
|
|
import com.discord.simpleast.core.parser.ParseSpec;
|
|
import com.discord.simpleast.core.parser.Parser;
|
|
import com.discord.simpleast.core.parser.Rule;
|
|
import com.discord.utilities.user.UserUtils;
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
|
import d0.g0.s;
|
|
import d0.z.d.m;
|
|
import java.util.Map;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
/* compiled from: MessageUnparser.kt */
|
|
public final class MessageUnparser$getUserMentionRule$1 extends Rule<T, Node<T>, S> {
|
|
public final /* synthetic */ Map $users;
|
|
public final /* synthetic */ MessageUnparser this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public MessageUnparser$getUserMentionRule$1(MessageUnparser messageUnparser, Map map, Pattern pattern) {
|
|
super(pattern);
|
|
this.this$0 = messageUnparser;
|
|
this.$users = map;
|
|
}
|
|
|
|
@Override // com.discord.simpleast.core.parser.Rule
|
|
public ParseSpec<T, S> parse(Matcher matcher, Parser<T, ? super Node<T>, S> parser, S s2) {
|
|
String str;
|
|
Long longOrNull;
|
|
m.checkNotNullParameter(matcher, "matcher");
|
|
m.checkNotNullParameter(parser, "parser");
|
|
String group = matcher.group(1);
|
|
User user = (User) this.$users.get(Long.valueOf((group == null || (longOrNull = s.toLongOrNull(group)) == null) ? -1 : longOrNull.longValue()));
|
|
if (user != null) {
|
|
StringBuilder J = a.J(MentionUtilsKt.MENTIONS_CHAR);
|
|
J.append(user.getUsername());
|
|
J.append(UserUtils.INSTANCE.getDiscriminatorWithPadding(user));
|
|
str = J.toString();
|
|
} else {
|
|
str = matcher.group();
|
|
}
|
|
m.checkNotNullExpressionValue(str, "content");
|
|
c.a.t.b.a.a aVar = new c.a.t.b.a.a(str);
|
|
m.checkNotNullParameter(aVar, "node");
|
|
return new ParseSpec<>(aVar, s2);
|
|
}
|
|
}
|