com.github.twitch4j.common.util.TwitchUtils Maven / Gradle / Ivy
package com.github.twitch4j.common.util;
import com.github.twitch4j.common.enums.CommandPermission;
import com.github.twitch4j.common.events.domain.EventUser;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
public class TwitchUtils {
/**
* The account used by twitch to signify an anonymous subscription gifter
*
* @see Official Announcement
*/
public static final EventUser ANONYMOUS_GIFTER = new EventUser("274598607", "ananonymousgifter");
/**
* The account used by twitch to signify an anonymous cheerer
*/
public static final EventUser ANONYMOUS_CHEERER = new EventUser("407665396", "ananonymouscheerer");
public static Set getPermissionsFromTags(Map tags) {
return getPermissionsFromTags(tags, new HashMap<>());
}
public static Set getPermissionsFromTags(@NonNull Map tags, @NonNull Map badges) {
return getPermissionsFromTags(tags, badges, null, null);
}
public static Set getPermissionsFromTags(@NonNull Map tags, @NonNull Map badges, String userId, Collection botOwnerIds) {
Set permissionSet = EnumSet.of(CommandPermission.EVERYONE);
// Check for Permissions
if (tags.containsKey("badges")) {
if (tags.get("badges") instanceof String) {
// needed for irc
badges.putAll(parseBadges((String) tags.get("badges")));
} else {
List