use of chatty.util.api.Emoticon 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.Emoticon in project chatty by chatty.
the class WebsocketManager method fetchEmoteSet.
/**
* Get the emotes from a specific emoteset, useable in the given room.
*
* @param room The channel the emotes should be useable in
* @param emoteset The FFZ emoteset to fetch
* @return A set of emotes or an empty set if an error occured
*/
private Set<Emoticon> fetchEmoteSet(String room, int emoteset) {
UrlRequest r = new UrlRequest("https://api.frankerfacez.com/v1/set/" + emoteset);
FullResult result = r.sync();
if (result.getResult() != null) {
Set<Emoticon> emotes = FrankerFaceZParsing.parseSetEmotes(result.getResult(), Emoticon.SubType.EVENT, room);
return emotes;
}
return new HashSet<>();
}
use of chatty.util.api.Emoticon in project chatty by chatty.
the class FrankerFaceZTest method testParseEmoteError.
private void testParseEmoteError(String fileName) throws Exception {
JSONParser parser = new JSONParser();
JSONObject obj = (JSONObject) parser.parse(loadJSON(fileName));
Emoticon emote = FrankerFaceZParsing.parseEmote(obj, null, null, null);
assertNull(emote);
}
use of chatty.util.api.Emoticon in project chatty by chatty.
the class EmojiUtil method main.
/**
* For testing.
*
* @param args
*/
public static void main(String[] args) {
Set<Emoticon> emotes = makeEmoticons("e1");
System.out.println(emotes.size());
for (Emoticon emote : emotes) {
System.out.println(emote.getInfos());
}
}
use of chatty.util.api.Emoticon in project chatty by chatty.
the class TwitchClient method commandMyEmotes.
/**
* Outputs the emotesets for the local user. This might not work correctly
* if the user is changed or the emotesets change during the session.
*/
private void commandMyEmotes() {
Set<Integer> emotesets = getSpecialUser().getEmoteSet();
if (emotesets.isEmpty()) {
g.printLine("No subscriber emotes found. (Only works if you joined" + " any channel before.)");
} else {
StringBuilder b = new StringBuilder("Your subemotes: ");
String sep = "";
for (Integer emoteset : emotesets) {
b.append(sep);
if (Emoticons.isTurboEmoteset(emoteset)) {
b.append("Turbo/Prime emotes");
} else {
String sep2 = "";
for (Emoticon emote : g.emoticons.getEmoticons(emoteset)) {
b.append(sep2);
b.append(emote.code);
sep2 = ", ";
}
}
sep = " / ";
}
g.printLine(b.toString());
}
}
Aggregations