use of chatty.util.api.EmoticonUpdate in project chatty by chatty.
the class FrankerFaceZ method parseResult.
private void parseResult(Type type, String stream, String result) {
if (result == null) {
return;
}
if (type == Type.FEATURE_FRIDAY && stream == null) {
// Response of the first request having only the info which channel
handleFeatureFriday(result);
return;
}
// Determine whether these emotes should be global
final boolean global = type == Type.GLOBAL || type == Type.FEATURE_FRIDAY;
String globalText = global ? "global" : "local";
Set<Emoticon> emotes = new HashSet<>();
List<Usericon> usericons = new ArrayList<>();
// Parse depending on type
if (type == Type.GLOBAL) {
emotes = FrankerFaceZParsing.parseGlobalEmotes(result);
} else if (type == Type.ROOM) {
emotes = FrankerFaceZParsing.parseRoomEmotes(result);
Usericon modIcon = FrankerFaceZParsing.parseModIcon(result);
if (modIcon != null) {
usericons.add(modIcon);
}
} else if (type == Type.FEATURE_FRIDAY) {
emotes = FrankerFaceZParsing.parseSetEmotes(result, Emoticon.SubType.FEATURE_FRIDAY, null);
for (Emoticon emote : emotes) {
if (featureFridayChannel != null) {
emote.setStream(featureFridayChannel);
}
}
}
LOGGER.info("[FFZ] (" + stream + ", " + globalText + "): " + emotes.size() + " emotes received.");
if (!usericons.isEmpty()) {
LOGGER.info("[FFZ] (" + stream + "): " + usericons.size() + " usericons received.");
}
// Package accordingly and send the result to the listener
EmoticonUpdate emotesUpdate;
if (type == Type.FEATURE_FRIDAY) {
emotesUpdate = new EmoticonUpdate(emotes, Emoticon.Type.FFZ, Emoticon.SubType.FEATURE_FRIDAY, null);
} else {
emotesUpdate = new EmoticonUpdate(emotes);
}
listener.channelEmoticonsReceived(emotesUpdate);
// Return icons if mod icon was found (will be empty otherwise)
listener.usericonsReceived(usericons);
}
use of chatty.util.api.EmoticonUpdate in project chatty by chatty.
the class WebsocketManager method fetchEmotes.
/**
* Fetches all emotes of the given emotesets, useable in the given room and
* sends them to the listener (removing previous EVENT emotes in that room).
*
* @param room The room the emotes will be useable in
* @param emotesets The set of FFZ emotesets
*/
private void fetchEmotes(String room, Set<Integer> emotesets) {
Set<Emoticon> result = new HashSet<>();
for (int set : emotesets) {
Set<Emoticon> fetched = fetchEmoteSet(room, set);
for (Emoticon emoteToAdd : fetched) {
// Add info to already existing emotes
for (Emoticon emote : result) {
if (emote.equals(emoteToAdd)) {
emote.addInfos(emoteToAdd.getInfos());
break;
}
}
// Add emote to result if not already added (Set)
result.add(emoteToAdd);
}
}
EmoticonUpdate update = new EmoticonUpdate(result, Emoticon.Type.FFZ, Emoticon.SubType.EVENT, room);
listener.channelEmoticonsReceived(update);
}
use of chatty.util.api.EmoticonUpdate in project chatty by chatty.
the class WebsocketManager method removeEmotes.
/**
* Sends an update to the listener to remove all FFZ EVENT emotes from the
* given room.
*
* @param room The channel the emotes should be removed from
*/
private void removeEmotes(String room) {
EmoticonUpdate update = new EmoticonUpdate(null, Emoticon.Type.FFZ, Emoticon.SubType.EVENT, room);
listener.channelEmoticonsReceived(update);
}
Aggregations