871 lines
47 KiB
Java
871 lines
47 KiB
Java
|
package com.discord.widgets.chat.input.applicationcommands;
|
||
|
|
||
|
import com.discord.api.commands.ApplicationCommandType;
|
||
|
import com.discord.api.commands.CommandChoice;
|
||
|
import com.discord.api.role.GuildRole;
|
||
|
import com.discord.api.sticker.Sticker;
|
||
|
import com.discord.models.commands.Application;
|
||
|
import com.discord.models.commands.ApplicationCommand;
|
||
|
import com.discord.models.commands.ApplicationCommandOption;
|
||
|
import com.discord.models.commands.ApplicationSubCommand;
|
||
|
import com.discord.models.user.User;
|
||
|
import com.discord.utilities.dsti.StickerUtils;
|
||
|
import com.discord.utilities.string.StringUtilsKt;
|
||
|
import com.discord.widgets.chat.input.ApplicationCommandData;
|
||
|
import com.discord.widgets.chat.input.ApplicationCommandValue;
|
||
|
import com.discord.widgets.chat.input.AutocompleteInputSelectionModel;
|
||
|
import com.discord.widgets.chat.input.BooleanOptionValue;
|
||
|
import com.discord.widgets.chat.input.ChannelOptionValue;
|
||
|
import com.discord.widgets.chat.input.ChatInputMentionsMap;
|
||
|
import com.discord.widgets.chat.input.CommandOptionValue;
|
||
|
import com.discord.widgets.chat.input.InputCommandOptions;
|
||
|
import com.discord.widgets.chat.input.InputSelectionModel;
|
||
|
import com.discord.widgets.chat.input.IntegerOptionValue;
|
||
|
import com.discord.widgets.chat.input.MentionToken;
|
||
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
||
|
import com.discord.widgets.chat.input.OptionRange;
|
||
|
import com.discord.widgets.chat.input.RawOptionValue;
|
||
|
import com.discord.widgets.chat.input.RoleOptionValue;
|
||
|
import com.discord.widgets.chat.input.SnowflakeOptionValue;
|
||
|
import com.discord.widgets.chat.input.StringOptionValue;
|
||
|
import com.discord.widgets.chat.input.UserAndSelectedGuildRoles;
|
||
|
import com.discord.widgets.chat.input.UserOptionValue;
|
||
|
import com.discord.widgets.chat.input.VerifiedCommandMentionInputModel;
|
||
|
import com.discord.widgets.chat.input.WidgetChatInputCommandsModel;
|
||
|
import com.discord.widgets.chat.input.sticker.StickerPickerFeatureFlag;
|
||
|
import d0.g0.s;
|
||
|
import d0.g0.t;
|
||
|
import d0.g0.w;
|
||
|
import d0.t.g0;
|
||
|
import d0.t.h0;
|
||
|
import d0.t.n;
|
||
|
import d0.t.n0;
|
||
|
import d0.t.o;
|
||
|
import d0.t.u;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.LinkedHashMap;
|
||
|
import java.util.LinkedHashSet;
|
||
|
import java.util.List;
|
||
|
import java.util.Locale;
|
||
|
import java.util.Map;
|
||
|
import java.util.Objects;
|
||
|
import java.util.Set;
|
||
|
import java.util.regex.Matcher;
|
||
|
import java.util.regex.Pattern;
|
||
|
import kotlin.NoWhenBranchMatchedException;
|
||
|
import kotlin.Pair;
|
||
|
import kotlin.ranges.IntRange;
|
||
|
/* compiled from: WidgetChatInputModelMappingFunctions.kt */
|
||
|
public final class WidgetChatInputModelMappingFunctions {
|
||
|
public static final WidgetChatInputModelMappingFunctions INSTANCE = new WidgetChatInputModelMappingFunctions();
|
||
|
private static final Pattern TAG_SYMBOLS_PATTERN;
|
||
|
private static final int TAG_SYMBOLS_PERF_LIMIT = 2000;
|
||
|
|
||
|
public final /* synthetic */ class WhenMappings {
|
||
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
||
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
||
|
public static final /* synthetic */ int[] $EnumSwitchMapping$2;
|
||
|
|
||
|
static {
|
||
|
ApplicationCommandType.values();
|
||
|
int[] iArr = new int[10];
|
||
|
$EnumSwitchMapping$0 = iArr;
|
||
|
ApplicationCommandType applicationCommandType = ApplicationCommandType.CHANNEL;
|
||
|
iArr[applicationCommandType.ordinal()] = 1;
|
||
|
ApplicationCommandType applicationCommandType2 = ApplicationCommandType.USER;
|
||
|
iArr[applicationCommandType2.ordinal()] = 2;
|
||
|
ApplicationCommandType applicationCommandType3 = ApplicationCommandType.ROLE;
|
||
|
iArr[applicationCommandType3.ordinal()] = 3;
|
||
|
ApplicationCommandType applicationCommandType4 = ApplicationCommandType.MENTIONABLE;
|
||
|
iArr[applicationCommandType4.ordinal()] = 4;
|
||
|
ApplicationCommandType applicationCommandType5 = ApplicationCommandType.BOOLEAN;
|
||
|
iArr[applicationCommandType5.ordinal()] = 5;
|
||
|
ApplicationCommandType.values();
|
||
|
int[] iArr2 = new int[10];
|
||
|
$EnumSwitchMapping$1 = iArr2;
|
||
|
ApplicationCommandType applicationCommandType6 = ApplicationCommandType.STRING;
|
||
|
iArr2[applicationCommandType6.ordinal()] = 1;
|
||
|
ApplicationCommandType applicationCommandType7 = ApplicationCommandType.INTEGER;
|
||
|
iArr2[applicationCommandType7.ordinal()] = 2;
|
||
|
iArr2[applicationCommandType5.ordinal()] = 3;
|
||
|
iArr2[applicationCommandType2.ordinal()] = 4;
|
||
|
iArr2[applicationCommandType.ordinal()] = 5;
|
||
|
iArr2[applicationCommandType3.ordinal()] = 6;
|
||
|
iArr2[applicationCommandType4.ordinal()] = 7;
|
||
|
ApplicationCommandType.values();
|
||
|
int[] iArr3 = new int[10];
|
||
|
$EnumSwitchMapping$2 = iArr3;
|
||
|
iArr3[ApplicationCommandType.SUBCOMMAND.ordinal()] = 1;
|
||
|
iArr3[ApplicationCommandType.SUBCOMMAND_GROUP.ordinal()] = 2;
|
||
|
iArr3[applicationCommandType6.ordinal()] = 3;
|
||
|
iArr3[applicationCommandType7.ordinal()] = 4;
|
||
|
iArr3[applicationCommandType5.ordinal()] = 5;
|
||
|
iArr3[applicationCommandType2.ordinal()] = 6;
|
||
|
iArr3[applicationCommandType.ordinal()] = 7;
|
||
|
iArr3[applicationCommandType3.ordinal()] = 8;
|
||
|
iArr3[applicationCommandType4.ordinal()] = 9;
|
||
|
iArr3[ApplicationCommandType.UNKNOWN.ordinal()] = 10;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
Pattern compile = Pattern.compile(".*(?:^|\\s)*[@#:/](.|\\n)*");
|
||
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(\".*(?:^|\\\\s)*[@#:/](.|\\\\n)*\")");
|
||
|
TAG_SYMBOLS_PATTERN = compile;
|
||
|
}
|
||
|
|
||
|
private WidgetChatInputModelMappingFunctions() {
|
||
|
}
|
||
|
|
||
|
private final MentionToken asMentionToken(String str, int i, boolean z2) {
|
||
|
if (str != null) {
|
||
|
boolean z3 = true;
|
||
|
Character valueOf = (!(t.isBlank(str) ^ true) || !MentionUtilsKt.getDEFAULT_LEADING_IDENTIFIERS().contains(Character.valueOf(str.charAt(0)))) ? null : Character.valueOf(str.charAt(0));
|
||
|
if (valueOf != null || z2) {
|
||
|
if (i != 0) {
|
||
|
z3 = false;
|
||
|
}
|
||
|
return new MentionToken(valueOf, str, z3);
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ MentionToken asMentionToken$default(WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions, String str, int i, boolean z2, int i2, Object obj) {
|
||
|
if ((i2 & 2) != 0) {
|
||
|
z2 = false;
|
||
|
}
|
||
|
return widgetChatInputModelMappingFunctions.asMentionToken(str, i, z2);
|
||
|
}
|
||
|
|
||
|
private final boolean isBoolean(String str) {
|
||
|
String str2;
|
||
|
if (str != null) {
|
||
|
Locale locale = Locale.getDefault();
|
||
|
m.checkNotNullExpressionValue(locale, "Locale.getDefault()");
|
||
|
str2 = str.toLowerCase(locale);
|
||
|
m.checkNotNullExpressionValue(str2, "(this as java.lang.String).toLowerCase(locale)");
|
||
|
} else {
|
||
|
str2 = null;
|
||
|
}
|
||
|
return m.areEqual(str2, "true") || m.areEqual(str2, "false");
|
||
|
}
|
||
|
|
||
|
private final boolean isSubRangeOf(IntRange intRange, IntRange intRange2) {
|
||
|
return !intRange.equals(intRange2) && intRange2.contains(intRange.getFirst()) && intRange2.contains(intRange.getLast());
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:128:0x0177 A[SYNTHETIC] */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:130:0x014a A[SYNTHETIC] */
|
||
|
public final List<WidgetChatInputCommandsModel> filterMentionsForCommandContext(InputSelectionModel inputSelectionModel) {
|
||
|
WidgetChatInputCommandsModel.Channel channel;
|
||
|
ArrayList arrayList;
|
||
|
boolean z2;
|
||
|
m.checkNotNullParameter(inputSelectionModel, "modelChat");
|
||
|
if (inputSelectionModel.getInputModel().getInputCommandContext().isCommand()) {
|
||
|
ApplicationCommandOption selectedCommandOption = inputSelectionModel.getSelectedCommandOption();
|
||
|
if (selectedCommandOption != null) {
|
||
|
List<CommandChoice> choices = selectedCommandOption.getChoices();
|
||
|
if (choices == null || !(!choices.isEmpty())) {
|
||
|
switch (selectedCommandOption.getType().ordinal()) {
|
||
|
case 4:
|
||
|
List<WidgetChatInputCommandsModel> createFromCommandOption = WidgetChatInputCommandsModel.createFromCommandOption(selectedCommandOption);
|
||
|
m.checkNotNullExpressionValue(createFromCommandOption, "WidgetChatInputCommandsM…FromCommandOption(option)");
|
||
|
return createFromCommandOption;
|
||
|
case 5:
|
||
|
List<WidgetChatInputCommandsModel> mentionables = inputSelectionModel.getInputModel().getMentionables();
|
||
|
arrayList = new ArrayList();
|
||
|
for (Object obj : mentionables) {
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel = (WidgetChatInputCommandsModel) obj;
|
||
|
if (widgetChatInputCommandsModel.getType() == 0 || widgetChatInputCommandsModel.getType() == 1 || widgetChatInputCommandsModel.getType() == 10) {
|
||
|
arrayList.add(obj);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case 6:
|
||
|
List<WidgetChatInputCommandsModel> mentionables2 = inputSelectionModel.getInputModel().getMentionables();
|
||
|
arrayList = new ArrayList();
|
||
|
for (Object obj2 : mentionables2) {
|
||
|
if (((WidgetChatInputCommandsModel) obj2).getType() == 2) {
|
||
|
arrayList.add(obj2);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case 7:
|
||
|
List<WidgetChatInputCommandsModel> mentionables3 = inputSelectionModel.getInputModel().getMentionables();
|
||
|
arrayList = new ArrayList();
|
||
|
for (Object obj3 : mentionables3) {
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel2 = (WidgetChatInputCommandsModel) obj3;
|
||
|
if (widgetChatInputCommandsModel2.getType() == 4 && widgetChatInputCommandsModel2.getRole() != null) {
|
||
|
arrayList.add(obj3);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case 8:
|
||
|
List<WidgetChatInputCommandsModel> mentionables4 = inputSelectionModel.getInputModel().getMentionables();
|
||
|
arrayList = new ArrayList();
|
||
|
for (Object obj4 : mentionables4) {
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel3 = (WidgetChatInputCommandsModel) obj4;
|
||
|
if (widgetChatInputCommandsModel3.getType() == 0 || widgetChatInputCommandsModel3.getType() == 1 || widgetChatInputCommandsModel3.getType() == 10 || (widgetChatInputCommandsModel3.getType() == 4 && widgetChatInputCommandsModel3.getRole() != null)) {
|
||
|
arrayList.add(obj4);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
List<WidgetChatInputCommandsModel> createFromCommandOption2 = WidgetChatInputCommandsModel.createFromCommandOption(selectedCommandOption);
|
||
|
m.checkNotNullExpressionValue(createFromCommandOption2, "WidgetChatInputCommandsM…FromCommandOption(option)");
|
||
|
List plus = u.plus((Collection) createFromCommandOption2, (Iterable) inputSelectionModel.getInputModel().getMentionables());
|
||
|
arrayList = new ArrayList();
|
||
|
for (Object obj5 : plus) {
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel4 = (WidgetChatInputCommandsModel) obj5;
|
||
|
if (widgetChatInputCommandsModel4.getType() == 2 || widgetChatInputCommandsModel4.getType() == 10) {
|
||
|
m.checkNotNullExpressionValue(widgetChatInputCommandsModel4, "it");
|
||
|
WidgetChatInputCommandsModel.Channel channel2 = widgetChatInputCommandsModel4.getChannel();
|
||
|
if (channel2 == null || !channel2.guildTextyChannel) {
|
||
|
z2 = false;
|
||
|
if (!z2) {
|
||
|
arrayList.add(obj5);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
z2 = true;
|
||
|
if (!z2) {
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
List<WidgetChatInputCommandsModel> createFromCommandOption3 = WidgetChatInputCommandsModel.createFromCommandOption(selectedCommandOption);
|
||
|
m.checkNotNullExpressionValue(createFromCommandOption3, "WidgetChatInputCommandsM…FromCommandOption(option)");
|
||
|
return createFromCommandOption3;
|
||
|
}
|
||
|
List<WidgetChatInputCommandsModel> mentionables5 = inputSelectionModel.getInputModel().getMentionables();
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
for (Object obj6 : mentionables5) {
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel5 = (WidgetChatInputCommandsModel) obj6;
|
||
|
if ((widgetChatInputCommandsModel5.getType() == 5 || widgetChatInputCommandsModel5.getType() == 6) ? false : true) {
|
||
|
arrayList2.add(obj6);
|
||
|
}
|
||
|
}
|
||
|
return arrayList2;
|
||
|
}
|
||
|
List<WidgetChatInputCommandsModel> mentionables6 = inputSelectionModel.getInputModel().getMentionables();
|
||
|
ArrayList arrayList3 = new ArrayList();
|
||
|
for (Object obj7 : mentionables6) {
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel6 = (WidgetChatInputCommandsModel) obj7;
|
||
|
if (!(widgetChatInputCommandsModel6.getType() == 2 || widgetChatInputCommandsModel6.getType() == 10) || ((channel = widgetChatInputCommandsModel6.getChannel()) != null && channel.guildTextyChannel)) {
|
||
|
arrayList3.add(obj7);
|
||
|
}
|
||
|
}
|
||
|
return arrayList3;
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Multi-variable search result rejected for r19v0, resolved type: java.util.Collection<? extends com.discord.widgets.chat.input.WidgetChatInputCommandsModel> */
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public final Collection<WidgetChatInputCommandsModel> filterMentionsFromToken(MentionToken mentionToken, InputSelectionModel inputSelectionModel, Collection<? extends WidgetChatInputCommandsModel> collection) {
|
||
|
Character leadingIdentifier;
|
||
|
m.checkNotNullParameter(mentionToken, "token");
|
||
|
m.checkNotNullParameter(inputSelectionModel, "inputSelectionModel");
|
||
|
m.checkNotNullParameter(collection, "mentions");
|
||
|
String formattedToken = mentionToken.getFormattedToken();
|
||
|
Locale locale = Locale.getDefault();
|
||
|
m.checkNotNullExpressionValue(locale, "Locale.getDefault()");
|
||
|
Objects.requireNonNull(formattedToken, "null cannot be cast to non-null type java.lang.String");
|
||
|
String lowerCase = formattedToken.toLowerCase(locale);
|
||
|
m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
||
|
String replace$default = t.replace$default(StringUtilsKt.stripAccents(lowerCase), " ", "", false, 4, (Object) null);
|
||
|
boolean z2 = (mentionToken.getFormattedToken().length() == 0) && mentionToken.getLeadingIdentifier() == null;
|
||
|
if (z2 && inputSelectionModel.hasSelectedOptionWithChoices()) {
|
||
|
return collection;
|
||
|
}
|
||
|
if (z2) {
|
||
|
return n.emptyList();
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (WidgetChatInputCommandsModel widgetChatInputCommandsModel : collection) {
|
||
|
String tag = widgetChatInputCommandsModel.getTag();
|
||
|
if (!(tag.length() == 0) && (mentionToken.isAtStart() || !widgetChatInputCommandsModel.isSlashCommand())) {
|
||
|
char charAt = tag.charAt(0);
|
||
|
if (mentionToken.getLeadingIdentifier() == null || ((leadingIdentifier = mentionToken.getLeadingIdentifier()) != null && charAt == leadingIdentifier.charValue())) {
|
||
|
Locale locale2 = Locale.getDefault();
|
||
|
m.checkNotNullExpressionValue(locale2, "Locale.getDefault()");
|
||
|
String lowerCase2 = tag.toLowerCase(locale2);
|
||
|
m.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase(locale)");
|
||
|
if (w.contains$default((CharSequence) t.replace$default(StringUtilsKt.stripAccents(lowerCase2), " ", "", false, 4, (Object) null), (CharSequence) replace$default, false, 2, (Object) null)) {
|
||
|
arrayList.add(widgetChatInputCommandsModel);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:52:0x013a */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:81:0x006e A[EDGE_INSN: B:81:0x006e->B:21:0x006e ?: BREAK , SYNTHETIC] */
|
||
|
public final ApplicationCommandData getApplicationSendData(AutocompleteInputSelectionModel autocompleteInputSelectionModel, List<? extends ApplicationCommand> list) {
|
||
|
InputSelectionModel inputSelectionModel;
|
||
|
VerifiedCommandMentionInputModel inputModel;
|
||
|
Object obj;
|
||
|
Object obj2;
|
||
|
boolean z2;
|
||
|
Object obj3;
|
||
|
boolean z3;
|
||
|
m.checkNotNullParameter(list, "queryCommands");
|
||
|
if (autocompleteInputSelectionModel == null || (inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null) {
|
||
|
return null;
|
||
|
}
|
||
|
ApplicationCommand selectedCommand = inputModel.getInputCommandContext().getSelectedCommand();
|
||
|
if (selectedCommand == null) {
|
||
|
Iterator<T> it = list.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
obj3 = null;
|
||
|
break;
|
||
|
}
|
||
|
obj3 = it.next();
|
||
|
ApplicationCommand applicationCommand = (ApplicationCommand) obj3;
|
||
|
String input = autocompleteInputSelectionModel.getInputSelectionModel().getInputModel().getInput();
|
||
|
if (!t.isBlank(input)) {
|
||
|
String name = applicationCommand.getName();
|
||
|
Objects.requireNonNull(input, "null cannot be cast to non-null type java.lang.String");
|
||
|
String substring = input.substring(1);
|
||
|
m.checkNotNullExpressionValue(substring, "(this as java.lang.String).substring(startIndex)");
|
||
|
if (m.areEqual(name, substring) && input.charAt(0) == '/') {
|
||
|
z3 = true;
|
||
|
continue;
|
||
|
if (z3) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
z3 = false;
|
||
|
continue;
|
||
|
if (z3) {
|
||
|
}
|
||
|
}
|
||
|
selectedCommand = (ApplicationCommand) obj3;
|
||
|
}
|
||
|
if (selectedCommand == null) {
|
||
|
return null;
|
||
|
}
|
||
|
Iterator<T> it2 = inputModel.getCommands().getApplications().iterator();
|
||
|
while (true) {
|
||
|
if (!it2.hasNext()) {
|
||
|
obj = null;
|
||
|
break;
|
||
|
}
|
||
|
obj = it2.next();
|
||
|
if (((Application) obj).getId() == selectedCommand.getApplicationId()) {
|
||
|
z2 = true;
|
||
|
continue;
|
||
|
} else {
|
||
|
z2 = false;
|
||
|
continue;
|
||
|
}
|
||
|
if (z2) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
Application application = (Application) obj;
|
||
|
if (application == null) {
|
||
|
return null;
|
||
|
}
|
||
|
Map<ApplicationCommandOption, CommandOptionValue> values = inputModel.getInputCommandOptions().getValues();
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap(g0.mapCapacity(values.size()));
|
||
|
Iterator<T> it3 = values.entrySet().iterator();
|
||
|
while (it3.hasNext()) {
|
||
|
Map.Entry entry = (Map.Entry) it3.next();
|
||
|
Object key = entry.getKey();
|
||
|
if (entry.getValue() instanceof StringOptionValue) {
|
||
|
List<CommandChoice> choices = ((ApplicationCommandOption) entry.getKey()).getChoices();
|
||
|
if (choices == null || choices.isEmpty()) {
|
||
|
obj2 = WidgetChatInputCommandsModel.replaceMatches(((CommandOptionValue) entry.getValue()).getValue().toString(), u.toMutableList((Collection) u.distinct(inputModel.getInputMentionsMap().values()))).getTextContent();
|
||
|
linkedHashMap.put(key, obj2);
|
||
|
}
|
||
|
}
|
||
|
obj2 = ((CommandOptionValue) entry.getValue()).getValue();
|
||
|
linkedHashMap.put(key, obj2);
|
||
|
}
|
||
|
Map<ApplicationCommandOption, Boolean> commandOptionValidity = inputModel.getInputCommandOptions().getCommandOptionValidity();
|
||
|
for (ApplicationCommandOption applicationCommandOption : selectedCommand.getOptions()) {
|
||
|
if ((applicationCommandOption.getRequired() && linkedHashMap.get(applicationCommandOption) == null) || m.areEqual(commandOptionValidity.get(applicationCommandOption), Boolean.FALSE)) {
|
||
|
return new ApplicationCommandData(application, selectedCommand, n.emptyList(), false);
|
||
|
}
|
||
|
while (r2.hasNext()) {
|
||
|
}
|
||
|
}
|
||
|
if (selectedCommand instanceof ApplicationSubCommand) {
|
||
|
Set<ApplicationCommandOption> keySet = linkedHashMap.keySet();
|
||
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(keySet, 10));
|
||
|
for (ApplicationCommandOption applicationCommandOption2 : keySet) {
|
||
|
Object obj4 = linkedHashMap.get(applicationCommandOption2);
|
||
|
if (obj4 == null) {
|
||
|
return null;
|
||
|
}
|
||
|
arrayList.add(new ApplicationCommandValue(applicationCommandOption2.getName(), obj4, applicationCommandOption2.getType().getType(), null, 8, null));
|
||
|
}
|
||
|
ApplicationSubCommand applicationSubCommand = (ApplicationSubCommand) selectedCommand;
|
||
|
ApplicationCommandValue applicationCommandValue = new ApplicationCommandValue(applicationSubCommand.getSubCommandName(), null, ApplicationCommandType.SUBCOMMAND.getType(), arrayList, 2, null);
|
||
|
return applicationSubCommand.getParentGroupName() != null ? new ApplicationCommandData(application, applicationSubCommand.getRootCommand(), d0.t.m.listOf(new ApplicationCommandValue(applicationSubCommand.getParentGroupName(), null, ApplicationCommandType.SUBCOMMAND_GROUP.getType(), d0.t.m.listOf(applicationCommandValue), 2, null)), true) : new ApplicationCommandData(application, applicationSubCommand.getRootCommand(), d0.t.m.listOf(applicationCommandValue), true);
|
||
|
}
|
||
|
Set<ApplicationCommandOption> keySet2 = linkedHashMap.keySet();
|
||
|
ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(keySet2, 10));
|
||
|
for (ApplicationCommandOption applicationCommandOption3 : keySet2) {
|
||
|
Object obj5 = linkedHashMap.get(applicationCommandOption3);
|
||
|
if (obj5 == null) {
|
||
|
return null;
|
||
|
}
|
||
|
arrayList2.add(new ApplicationCommandValue(applicationCommandOption3.getName(), obj5, applicationCommandOption3.getType().getType(), null, 8, null));
|
||
|
}
|
||
|
return new ApplicationCommandData(application, selectedCommand, arrayList2, true);
|
||
|
}
|
||
|
|
||
|
public final Set<ApplicationCommandOption> getErrorsToShowForCommandParameters(ApplicationCommand applicationCommand, ApplicationCommandOption applicationCommandOption, ApplicationCommandOption applicationCommandOption2, Map<ApplicationCommandOption, Boolean> map, Map<ApplicationCommandOption, ? extends CommandOptionValue> map2) {
|
||
|
m.checkNotNullParameter(map, "validMap");
|
||
|
m.checkNotNullParameter(map2, "parsedCommandOptions");
|
||
|
LinkedHashSet linkedHashSet = new LinkedHashSet();
|
||
|
if (applicationCommand == null) {
|
||
|
return n0.emptySet();
|
||
|
}
|
||
|
for (ApplicationCommandOption applicationCommandOption3 : applicationCommand.getOptions()) {
|
||
|
if (map2.containsKey(applicationCommandOption3)) {
|
||
|
CommandOptionValue commandOptionValue = (CommandOptionValue) map2.get(applicationCommandOption3);
|
||
|
String valueOf = String.valueOf(commandOptionValue != null ? commandOptionValue.getValue() : null);
|
||
|
boolean z2 = false;
|
||
|
boolean z3 = t.isBlank(valueOf) || (valueOf.length() == 1 && MentionUtilsKt.getDEFAULT_LEADING_IDENTIFIERS().contains(Character.valueOf(valueOf.charAt(0))));
|
||
|
boolean areEqual = m.areEqual(applicationCommandOption, applicationCommandOption3);
|
||
|
boolean z4 = applicationCommandOption2 != null && m.areEqual(applicationCommandOption2, applicationCommandOption3);
|
||
|
boolean containsKey = map2.containsKey(applicationCommandOption3);
|
||
|
boolean z5 = (areEqual && z4) || (areEqual && z3);
|
||
|
if (m.areEqual(map.get(applicationCommandOption3), Boolean.FALSE) && !z5 && containsKey) {
|
||
|
z2 = true;
|
||
|
}
|
||
|
if (z2) {
|
||
|
linkedHashSet.add(applicationCommandOption3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return linkedHashSet;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:28:0x008a, code lost:
|
||
|
if ((r2 instanceof com.discord.widgets.chat.input.SnowflakeOptionValue) == false) goto L_0x00c2;
|
||
|
*/
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:32:0x0093, code lost:
|
||
|
if ((r2 instanceof com.discord.widgets.chat.input.SnowflakeOptionValue) == false) goto L_0x00c2;
|
||
|
*/
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:36:0x009c, code lost:
|
||
|
if ((r2 instanceof com.discord.widgets.chat.input.SnowflakeOptionValue) == false) goto L_0x00c2;
|
||
|
*/
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:40:0x00a5, code lost:
|
||
|
if ((r2 instanceof com.discord.widgets.chat.input.SnowflakeOptionValue) == false) goto L_0x00c2;
|
||
|
*/
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:46:0x00bf, code lost:
|
||
|
if ((!d0.g0.t.isBlank(r2.getValue().toString())) != false) goto L_0x007e;
|
||
|
*/
|
||
|
public final Map<ApplicationCommandOption, Boolean> getInputValidity(ApplicationCommand applicationCommand, Map<ApplicationCommandOption, ? extends CommandOptionValue> map) {
|
||
|
m.checkNotNullParameter(applicationCommand, "selectedCommand");
|
||
|
m.checkNotNullParameter(map, "parsedCommandOptions");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||
|
for (ApplicationCommandOption applicationCommandOption : applicationCommand.getOptions()) {
|
||
|
CommandOptionValue commandOptionValue = (CommandOptionValue) map.get(applicationCommandOption);
|
||
|
if (commandOptionValue != null) {
|
||
|
List<CommandChoice> choices = applicationCommandOption.getChoices();
|
||
|
boolean z2 = false;
|
||
|
if (choices == null || !(!choices.isEmpty())) {
|
||
|
switch (applicationCommandOption.getType().ordinal()) {
|
||
|
case 0:
|
||
|
case 1:
|
||
|
break;
|
||
|
case 2:
|
||
|
if (commandOptionValue instanceof StringOptionValue) {
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case 3:
|
||
|
z2 = commandOptionValue instanceof IntegerOptionValue;
|
||
|
break;
|
||
|
case 4:
|
||
|
z2 = commandOptionValue instanceof BooleanOptionValue;
|
||
|
break;
|
||
|
case 5:
|
||
|
if (!(commandOptionValue instanceof UserOptionValue)) {
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case 6:
|
||
|
if (!(commandOptionValue instanceof ChannelOptionValue)) {
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case 7:
|
||
|
if (!(commandOptionValue instanceof RoleOptionValue)) {
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case 8:
|
||
|
if (!(commandOptionValue instanceof UserOptionValue)) {
|
||
|
if (!(commandOptionValue instanceof RoleOptionValue)) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case 9:
|
||
|
break;
|
||
|
default:
|
||
|
throw new NoWhenBranchMatchedException();
|
||
|
}
|
||
|
linkedHashMap.put(applicationCommandOption, Boolean.valueOf(z2));
|
||
|
} else {
|
||
|
List<CommandChoice> choices2 = applicationCommandOption.getChoices();
|
||
|
if (!(choices2 instanceof Collection) || !choices2.isEmpty()) {
|
||
|
Iterator<T> it = choices2.iterator();
|
||
|
while (true) {
|
||
|
if (it.hasNext()) {
|
||
|
if (m.areEqual(((CommandChoice) it.next()).b(), commandOptionValue.getValue().toString())) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
linkedHashMap.put(applicationCommandOption, Boolean.valueOf(z2));
|
||
|
}
|
||
|
z2 = true;
|
||
|
linkedHashMap.put(applicationCommandOption, Boolean.valueOf(z2));
|
||
|
} else if (applicationCommandOption.getRequired()) {
|
||
|
linkedHashMap.put(applicationCommandOption, Boolean.FALSE);
|
||
|
}
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public final MentionToken getMentionAutoCompleteToken(String str, IntRange intRange, ApplicationCommandOption applicationCommandOption, boolean z2, InputCommandOptions inputCommandOptions) {
|
||
|
int i;
|
||
|
String str2;
|
||
|
m.checkNotNullParameter(str, "input");
|
||
|
m.checkNotNullParameter(intRange, "selection");
|
||
|
m.checkNotNullParameter(inputCommandOptions, "inputCommandOptions");
|
||
|
Pair<String, Integer> selectedToken = MentionUtilsKt.getSelectedToken(str, intRange.getFirst());
|
||
|
String component1 = selectedToken.component1();
|
||
|
int intValue = selectedToken.component2().intValue();
|
||
|
if (applicationCommandOption != null) {
|
||
|
IntRange intRange2 = null;
|
||
|
if (component1 != null) {
|
||
|
component1 = w.removePrefix(component1, applicationCommandOption.getName() + ":");
|
||
|
} else {
|
||
|
component1 = null;
|
||
|
}
|
||
|
if (!z2) {
|
||
|
OptionRange optionRange = inputCommandOptions.getInputRanges().get(applicationCommandOption);
|
||
|
if (optionRange != null) {
|
||
|
intRange2 = optionRange.getValue();
|
||
|
}
|
||
|
CommandOptionValue commandOptionValue = inputCommandOptions.getValues().get(applicationCommandOption);
|
||
|
if (!(intRange2 == null || commandOptionValue == null || intRange.getFirst() <= intRange2.getFirst())) {
|
||
|
String obj = commandOptionValue.getValue().toString();
|
||
|
int min = Math.min(intRange.getFirst() - intRange2.getFirst(), commandOptionValue.getValue().toString().length());
|
||
|
Objects.requireNonNull(obj, "null cannot be cast to non-null type java.lang.String");
|
||
|
component1 = obj.substring(0, min);
|
||
|
m.checkNotNullExpressionValue(component1, "(this as java.lang.Strin…ing(startIndex, endIndex)");
|
||
|
}
|
||
|
WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions = INSTANCE;
|
||
|
if (component1 == null) {
|
||
|
component1 = "";
|
||
|
}
|
||
|
return widgetChatInputModelMappingFunctions.asMentionToken(component1, intValue, true);
|
||
|
}
|
||
|
MentionToken asMentionToken$default = asMentionToken$default(INSTANCE, component1, intValue, false, 2, null);
|
||
|
if (asMentionToken$default != null) {
|
||
|
return asMentionToken$default;
|
||
|
}
|
||
|
}
|
||
|
Pattern compile = Pattern.compile("^(/([a-zA-Z0-9_-]+\\s*){1,3})(.|\\n)*");
|
||
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(\"^(/([a-…_-]+\\\\s*){1,3})(.|\\\\n)*\")");
|
||
|
Matcher matcher = compile.matcher(str);
|
||
|
if (matcher.matches()) {
|
||
|
str2 = matcher.group(0);
|
||
|
i = 0;
|
||
|
} else {
|
||
|
i = intValue;
|
||
|
str2 = component1;
|
||
|
}
|
||
|
return asMentionToken$default(this, str2, i, false, 2, null);
|
||
|
}
|
||
|
|
||
|
public final ApplicationCommand getSelectedCommand(List<? extends ApplicationCommand> list, String str, String str2, UserAndSelectedGuildRoles userAndSelectedGuildRoles) {
|
||
|
boolean z2;
|
||
|
m.checkNotNullParameter(list, "commands");
|
||
|
m.checkNotNullParameter(str, "prefix");
|
||
|
m.checkNotNullParameter(str2, "input");
|
||
|
m.checkNotNullParameter(userAndSelectedGuildRoles, "userAndRoles");
|
||
|
Object obj = null;
|
||
|
if (!(str.length() > 0)) {
|
||
|
return null;
|
||
|
}
|
||
|
Iterator<T> it = list.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
break;
|
||
|
}
|
||
|
Object next = it.next();
|
||
|
ApplicationCommand applicationCommand = (ApplicationCommand) next;
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
String name = applicationCommand.getName();
|
||
|
sb.append(String.valueOf('/') + name);
|
||
|
sb.append(' ');
|
||
|
if (!t.startsWith$default(str2, sb.toString(), false, 2, null) || !WidgetChatInputModelMappingFunctionsKt.hasPermission(applicationCommand, userAndSelectedGuildRoles)) {
|
||
|
z2 = false;
|
||
|
continue;
|
||
|
} else {
|
||
|
z2 = true;
|
||
|
continue;
|
||
|
}
|
||
|
if (z2) {
|
||
|
obj = next;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return (ApplicationCommand) obj;
|
||
|
}
|
||
|
|
||
|
public final ApplicationCommandOption getSelectedOption(int i, Map<ApplicationCommandOption, OptionRange> map) {
|
||
|
Set<ApplicationCommandOption> keySet;
|
||
|
if (map == null || (keySet = map.keySet()) == null) {
|
||
|
return null;
|
||
|
}
|
||
|
for (ApplicationCommandOption applicationCommandOption : keySet) {
|
||
|
OptionRange optionRange = map.get(applicationCommandOption);
|
||
|
if (optionRange != null && optionRange.getParam().getFirst() < i && optionRange.getValue().getLast() >= i) {
|
||
|
return applicationCommandOption;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public final List<Sticker> getStickerMatches(MentionToken mentionToken) {
|
||
|
if (StickerPickerFeatureFlag.Companion.getINSTANCE().isEnabled()) {
|
||
|
Character leadingIdentifier = mentionToken != null ? mentionToken.getLeadingIdentifier() : null;
|
||
|
if (leadingIdentifier != null && leadingIdentifier.charValue() == ':') {
|
||
|
String token = mentionToken.getToken();
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
int length = token.length();
|
||
|
for (int i = 0; i < length; i++) {
|
||
|
char charAt = token.charAt(i);
|
||
|
if (Character.isLetterOrDigit(charAt)) {
|
||
|
sb.append(charAt);
|
||
|
}
|
||
|
}
|
||
|
String sb2 = sb.toString();
|
||
|
m.checkNotNullExpressionValue(sb2, "filterTo(StringBuilder(), predicate).toString()");
|
||
|
if (sb2.length() - 1 >= 3) {
|
||
|
return u.toList(StickerUtils.INSTANCE.findStickerMatches(t.replace(mentionToken.getToken(), String.valueOf(mentionToken.getLeadingIdentifier().charValue()), "", true), n.emptyList(), true));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return n.emptyList();
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:40:0x00db, code lost:
|
||
|
r5 = false;
|
||
|
*/
|
||
|
public final ChatInputMentionsMap mapInputToMentions(String str, Collection<? extends WidgetChatInputCommandsModel> collection, boolean z2) {
|
||
|
boolean z3;
|
||
|
m.checkNotNullParameter(str, "input");
|
||
|
m.checkNotNullParameter(collection, "unfilteredMentionables");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||
|
ArrayList<WidgetChatInputCommandsModel> arrayList = new ArrayList();
|
||
|
Iterator<T> it = collection.iterator();
|
||
|
while (true) {
|
||
|
boolean z4 = false;
|
||
|
if (!it.hasNext()) {
|
||
|
break;
|
||
|
}
|
||
|
Object next = it.next();
|
||
|
if (((WidgetChatInputCommandsModel) next).getType() != 10) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
if (z4) {
|
||
|
arrayList.add(next);
|
||
|
}
|
||
|
}
|
||
|
if (!(arrayList.size() <= 2000 || z2 || TAG_SYMBOLS_PATTERN.matcher(str).matches())) {
|
||
|
return new ChatInputMentionsMap(str, h0.emptyMap());
|
||
|
}
|
||
|
for (WidgetChatInputCommandsModel widgetChatInputCommandsModel : arrayList) {
|
||
|
String displayTag = widgetChatInputCommandsModel.getDisplayTag();
|
||
|
m.checkNotNullExpressionValue(displayTag, "commandModel.displayTag");
|
||
|
int indexOf$default = w.indexOf$default((CharSequence) str, displayTag, 0, false, 4, (Object) null);
|
||
|
while (indexOf$default != -1) {
|
||
|
IntRange intRange = new IntRange(indexOf$default, displayTag.length() + indexOf$default);
|
||
|
if (linkedHashMap.isEmpty()) {
|
||
|
linkedHashMap.put(intRange, widgetChatInputCommandsModel);
|
||
|
} else {
|
||
|
Iterator it2 = linkedHashMap.entrySet().iterator();
|
||
|
while (true) {
|
||
|
if (!it2.hasNext()) {
|
||
|
z3 = true;
|
||
|
break;
|
||
|
}
|
||
|
Map.Entry entry = (Map.Entry) it2.next();
|
||
|
IntRange intRange2 = (IntRange) entry.getKey();
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel2 = (WidgetChatInputCommandsModel) entry.getValue();
|
||
|
if (!m.areEqual(intRange, intRange2) || widgetChatInputCommandsModel.getType() != 4 || widgetChatInputCommandsModel2.getType() == 4) {
|
||
|
WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions = INSTANCE;
|
||
|
if (!widgetChatInputModelMappingFunctions.isSubRangeOf(intRange2, intRange)) {
|
||
|
if (m.areEqual(intRange, intRange2) || widgetChatInputModelMappingFunctions.isSubRangeOf(intRange, intRange2)) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
it2.remove();
|
||
|
}
|
||
|
if (z3) {
|
||
|
linkedHashMap.put(intRange, widgetChatInputCommandsModel);
|
||
|
}
|
||
|
}
|
||
|
indexOf$default = w.indexOf$default((CharSequence) str, displayTag, indexOf$default + 1, false, 4, (Object) null);
|
||
|
}
|
||
|
}
|
||
|
return new ChatInputMentionsMap(str, linkedHashMap);
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Code restructure failed: missing block: B:22:0x00c3, code lost:
|
||
|
if (r4 != null) goto L_0x00c7;
|
||
|
*/
|
||
|
public final Map<ApplicationCommandOption, CommandOptionValue> parseCommandOptions(String str, ApplicationCommand applicationCommand, ChatInputMentionsMap chatInputMentionsMap) {
|
||
|
CommandOptionValue commandOptionValue;
|
||
|
Object obj;
|
||
|
String str2;
|
||
|
CommandOptionValue integerOptionValue;
|
||
|
User user;
|
||
|
WidgetChatInputCommandsModel.Channel channel;
|
||
|
GuildRole role;
|
||
|
Object obj2;
|
||
|
m.checkNotNullParameter(str, "input");
|
||
|
m.checkNotNullParameter(applicationCommand, "command");
|
||
|
m.checkNotNullParameter(chatInputMentionsMap, "mentionMap");
|
||
|
Map<ApplicationCommandOption, OptionRange> findOptionRanges = WidgetChatInputApplicationCommandsKt.findOptionRanges(str, applicationCommand);
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||
|
for (ApplicationCommandOption applicationCommandOption : findOptionRanges.keySet()) {
|
||
|
OptionRange optionRange = findOptionRanges.get(applicationCommandOption);
|
||
|
if (optionRange != null) {
|
||
|
String substring = str.substring(optionRange.getValue().getFirst(), optionRange.getValue().getLast());
|
||
|
m.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
|
||
|
Objects.requireNonNull(substring, "null cannot be cast to non-null type kotlin.CharSequence");
|
||
|
String obj3 = w.trim(substring).toString();
|
||
|
Iterator<T> it = chatInputMentionsMap.getMentions().values().iterator();
|
||
|
while (true) {
|
||
|
commandOptionValue = null;
|
||
|
if (it.hasNext()) {
|
||
|
obj = it.next();
|
||
|
if (m.areEqual(((WidgetChatInputCommandsModel) obj).getDisplayTag(), obj3)) {
|
||
|
}
|
||
|
} else {
|
||
|
obj = null;
|
||
|
}
|
||
|
}
|
||
|
WidgetChatInputCommandsModel widgetChatInputCommandsModel = (WidgetChatInputCommandsModel) obj;
|
||
|
List<CommandChoice> choices = applicationCommandOption.getChoices();
|
||
|
if (choices != null) {
|
||
|
Iterator<T> it2 = choices.iterator();
|
||
|
while (true) {
|
||
|
if (it2.hasNext()) {
|
||
|
obj2 = it2.next();
|
||
|
String a = ((CommandChoice) obj2).a();
|
||
|
Objects.requireNonNull(a, "null cannot be cast to non-null type kotlin.CharSequence");
|
||
|
String obj4 = w.trim(a).toString();
|
||
|
Objects.requireNonNull(obj3, "null cannot be cast to non-null type kotlin.CharSequence");
|
||
|
if (m.areEqual(obj4, w.trim(obj3).toString())) {
|
||
|
}
|
||
|
} else {
|
||
|
obj2 = null;
|
||
|
}
|
||
|
}
|
||
|
CommandChoice commandChoice = (CommandChoice) obj2;
|
||
|
if (commandChoice != null) {
|
||
|
str2 = commandChoice.b();
|
||
|
}
|
||
|
}
|
||
|
str2 = obj3;
|
||
|
switch (applicationCommandOption.getType().ordinal()) {
|
||
|
case 2:
|
||
|
commandOptionValue = new StringOptionValue(str2);
|
||
|
break;
|
||
|
case 3:
|
||
|
Integer intOrNull = s.toIntOrNull(str2);
|
||
|
if (intOrNull != null) {
|
||
|
integerOptionValue = new IntegerOptionValue(intOrNull.intValue());
|
||
|
commandOptionValue = integerOptionValue;
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case 4:
|
||
|
if (INSTANCE.isBoolean(obj3)) {
|
||
|
integerOptionValue = new BooleanOptionValue(Boolean.parseBoolean(str2));
|
||
|
commandOptionValue = integerOptionValue;
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case 5:
|
||
|
if (!(widgetChatInputCommandsModel == null || (user = widgetChatInputCommandsModel.getUser()) == null)) {
|
||
|
integerOptionValue = new UserOptionValue(user);
|
||
|
commandOptionValue = integerOptionValue;
|
||
|
break;
|
||
|
}
|
||
|
case 6:
|
||
|
if (!(widgetChatInputCommandsModel == null || (channel = widgetChatInputCommandsModel.getChannel()) == null)) {
|
||
|
integerOptionValue = new ChannelOptionValue(channel);
|
||
|
commandOptionValue = integerOptionValue;
|
||
|
break;
|
||
|
}
|
||
|
case 7:
|
||
|
if (!(widgetChatInputCommandsModel == null || (role = widgetChatInputCommandsModel.getRole()) == null)) {
|
||
|
integerOptionValue = new RoleOptionValue(role);
|
||
|
commandOptionValue = integerOptionValue;
|
||
|
break;
|
||
|
}
|
||
|
case 8:
|
||
|
if ((widgetChatInputCommandsModel != null ? widgetChatInputCommandsModel.getUser() : null) == null) {
|
||
|
if ((widgetChatInputCommandsModel != null ? widgetChatInputCommandsModel.getRole() : null) != null) {
|
||
|
GuildRole role2 = widgetChatInputCommandsModel.getRole();
|
||
|
m.checkNotNullExpressionValue(role2, "mention.role");
|
||
|
commandOptionValue = new RoleOptionValue(role2);
|
||
|
break;
|
||
|
}
|
||
|
} else {
|
||
|
User user2 = widgetChatInputCommandsModel.getUser();
|
||
|
m.checkNotNullExpressionValue(user2, "mention.user");
|
||
|
commandOptionValue = new UserOptionValue(user2);
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
if (commandOptionValue != null) {
|
||
|
linkedHashMap.put(applicationCommandOption, commandOptionValue);
|
||
|
} else {
|
||
|
Long snowflake = INSTANCE.toSnowflake(obj3);
|
||
|
if (snowflake != null) {
|
||
|
linkedHashMap.put(applicationCommandOption, new SnowflakeOptionValue(snowflake.longValue()));
|
||
|
} else {
|
||
|
linkedHashMap.put(applicationCommandOption, new RawOptionValue(obj3));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public final Long toSnowflake(String str) {
|
||
|
m.checkNotNullParameter(str, "text");
|
||
|
Long longOrNull = s.toLongOrNull(str);
|
||
|
if (longOrNull == null || longOrNull.longValue() <= 1420070400000L) {
|
||
|
return null;
|
||
|
}
|
||
|
return longOrNull;
|
||
|
}
|
||
|
}
|