121 lines
5.3 KiB
Java
121 lines
5.3 KiB
Java
package com.discord.utilities.message;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Configuration;
|
|
import android.content.res.Resources;
|
|
import android.os.Build;
|
|
import android.os.LocaleList;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.channel.ChannelRecipientNick;
|
|
import com.discord.api.interaction.Interaction;
|
|
import com.discord.api.user.User;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.message.Message;
|
|
import com.discord.models.user.CoreUser;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import d0.z.d.m;
|
|
import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
/* compiled from: MessageUtils.kt */
|
|
public final class MessageUtils {
|
|
public static final MessageUtils INSTANCE = new MessageUtils();
|
|
private static final Comparator<Long> SORT_BY_IDS_COMPARATOR = MessageUtils$SORT_BY_IDS_COMPARATOR$1.INSTANCE;
|
|
private static final int[] WELCOME_MESSAGES = {2131893944, 2131893945, 2131893946, 2131893947, 2131893948, 2131893949, 2131893950, 2131893951, 2131893952, 2131893953, 2131893954, 2131893955, 2131893956};
|
|
|
|
private MessageUtils() {
|
|
}
|
|
|
|
public static final int compareMessages(Long l, Long l2) {
|
|
long j = 0;
|
|
long longValue = l != null ? l.longValue() : 0;
|
|
if (l2 != null) {
|
|
j = l2.longValue();
|
|
}
|
|
int i = (longValue > j ? 1 : (longValue == j ? 0 : -1));
|
|
if (i == 0) {
|
|
return 0;
|
|
}
|
|
return i < 0 ? -1 : 1;
|
|
}
|
|
|
|
public static final Map<Long, String> getNickOrUsernames(Message message, Channel channel, Map<Long, GuildMember> map, List<ChannelRecipientNick> list) {
|
|
m.checkNotNullParameter(message, "message");
|
|
m.checkNotNullParameter(map, "channelMembers");
|
|
List<User> mentions = message.getMentions();
|
|
HashMap hashMap = new HashMap((mentions != null ? mentions.size() : 0) + 1);
|
|
List<User> mentions2 = message.getMentions();
|
|
if (mentions2 != null) {
|
|
for (User user : mentions2) {
|
|
hashMap.put(Long.valueOf(user.i()), GuildMember.Companion.getNickOrUsername(new CoreUser(user), map.get(Long.valueOf(user.i())), channel, list));
|
|
}
|
|
}
|
|
User author = message.getAuthor();
|
|
if (author != null) {
|
|
hashMap.put(Long.valueOf(author.i()), GuildMember.Companion.getNickOrUsername(new CoreUser(author), map.get(Long.valueOf(author.i())), channel, list));
|
|
}
|
|
Interaction interaction = message.getInteraction();
|
|
User c2 = interaction != null ? interaction.c() : null;
|
|
if (c2 != null) {
|
|
hashMap.put(Long.valueOf(c2.i()), GuildMember.Companion.getNickOrUsername(new CoreUser(c2), map.get(Long.valueOf(c2.i())), channel, list));
|
|
}
|
|
return hashMap;
|
|
}
|
|
|
|
public static /* synthetic */ Map getNickOrUsernames$default(Message message, Channel channel, Map map, List list, int i, Object obj) {
|
|
if ((i & 8) != 0) {
|
|
list = null;
|
|
}
|
|
return getNickOrUsernames(message, channel, map, list);
|
|
}
|
|
|
|
public static final Comparator<Long> getSORT_BY_IDS_COMPARATOR() {
|
|
return SORT_BY_IDS_COMPARATOR;
|
|
}
|
|
|
|
public static /* synthetic */ void getSORT_BY_IDS_COMPARATOR$annotations() {
|
|
}
|
|
|
|
public static final boolean isNewer(Long l, Long l2) {
|
|
return compareMessages(l, l2) < 0;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:17:0x003d */
|
|
/* JADX WARNING: Removed duplicated region for block: B:20:0x004d */
|
|
/* JADX WARNING: Removed duplicated region for block: B:21:0x0050 */
|
|
public final int getSystemMessageUserJoin(Context context, long j) {
|
|
Locale locale;
|
|
Configuration configuration;
|
|
Configuration configuration2;
|
|
LocaleList locales;
|
|
m.checkNotNullParameter(context, "context");
|
|
String str = null;
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
Resources resources = context.getResources();
|
|
if (!(resources == null || (configuration2 = resources.getConfiguration()) == null || (locales = configuration2.getLocales()) == null)) {
|
|
locale = locales.get(0);
|
|
Locale locale2 = new Locale("en");
|
|
if (locale != null) {
|
|
str = locale.getLanguage();
|
|
}
|
|
return WELCOME_MESSAGES[(int) (m.areEqual(str, locale2.getLanguage()) ^ true ? 0 : TimeUtils.parseSnowflake(Long.valueOf(j)) % ((long) WELCOME_MESSAGES.length))];
|
|
}
|
|
} else {
|
|
Resources resources2 = context.getResources();
|
|
if (!(resources2 == null || (configuration = resources2.getConfiguration()) == null)) {
|
|
locale = configuration.locale;
|
|
Locale locale2 = new Locale("en");
|
|
if (locale != null) {
|
|
}
|
|
return WELCOME_MESSAGES[(int) (m.areEqual(str, locale2.getLanguage()) ^ true ? 0 : TimeUtils.parseSnowflake(Long.valueOf(j)) % ((long) WELCOME_MESSAGES.length))];
|
|
}
|
|
}
|
|
locale = null;
|
|
Locale locale2 = new Locale("en");
|
|
if (locale != null) {
|
|
}
|
|
return WELCOME_MESSAGES[(int) (m.areEqual(str, locale2.getLanguage()) ^ true ? 0 : TimeUtils.parseSnowflake(Long.valueOf(j)) % ((long) WELCOME_MESSAGES.length))];
|
|
}
|
|
}
|