2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.utilities.textprocessing;
|
|
|
|
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.discord.api.role.GuildRole;
|
|
|
|
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.widgets.chat.input.MentionUtilsKt;
|
|
|
|
import d0.g0.s;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
/* compiled from: MessageUnparser.kt */
|
|
|
|
public final class MessageUnparser$getRoleMentionRule$1 extends Rule<T, Node<T>, S> {
|
|
|
|
public final /* synthetic */ List $guildRoles;
|
|
|
|
public final /* synthetic */ MessageUnparser this$0;
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public MessageUnparser$getRoleMentionRule$1(MessageUnparser messageUnparser, List list, Pattern pattern) {
|
|
|
|
super(pattern);
|
|
|
|
this.this$0 = messageUnparser;
|
|
|
|
this.$guildRoles = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.simpleast.core.parser.Rule
|
|
|
|
public ParseSpec<T, S> parse(Matcher matcher, Parser<T, ? super Node<T>, S> parser, S s2) {
|
|
|
|
Object obj;
|
|
|
|
String str;
|
|
|
|
boolean z2;
|
|
|
|
Long longOrNull;
|
|
|
|
m.checkNotNullParameter(matcher, "matcher");
|
|
|
|
m.checkNotNullParameter(parser, "parser");
|
|
|
|
String group = matcher.group(1);
|
|
|
|
long longValue = (group == null || (longOrNull = s.toLongOrNull(group)) == null) ? -1 : longOrNull.longValue();
|
|
|
|
Iterator it = this.$guildRoles.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (!it.hasNext()) {
|
|
|
|
obj = null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
obj = it.next();
|
|
|
|
if (((GuildRole) obj).getId() == longValue) {
|
|
|
|
z2 = true;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
z2 = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GuildRole guildRole = (GuildRole) obj;
|
|
|
|
if (guildRole != null) {
|
2021-08-18 07:29:27 +00:00
|
|
|
StringBuilder J = a.J(MentionUtilsKt.MENTIONS_CHAR);
|
|
|
|
J.append(guildRole.f());
|
|
|
|
str = J.toString();
|
2021-08-09 22:50:52 +00:00
|
|
|
} else {
|
|
|
|
str = matcher.group();
|
|
|
|
}
|
|
|
|
m.checkNotNullExpressionValue(str, "content");
|
2021-08-18 07:29:27 +00:00
|
|
|
c.a.t.b.a.a aVar = new c.a.t.b.a.a(str);
|
2021-08-09 22:50:52 +00:00
|
|
|
m.checkNotNullParameter(aVar, "node");
|
|
|
|
return new ParseSpec<>(aVar, s2);
|
|
|
|
}
|
|
|
|
}
|