-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Badges in twitch messages now display as emotes. They can be disabled as any emotes, this causes the old badge texts to be used. Also, added support for displaying more than one badge at once, both image and text type This fixes #6 (or rather implements that idea, but ya know - github wouldn't auto-close that issue if I wrote "implements")
- Loading branch information
1 parent
e7cb6cc
commit 8fea193
Showing
7 changed files
with
154 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/me/mini_bomba/streamchatmod/utils/TwitchGlobalBadge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.mini_bomba.streamchatmod.utils; | ||
|
||
import com.github.twitch4j.helix.domain.ChatBadge; | ||
import com.github.twitch4j.helix.domain.ChatBadgeSet; | ||
|
||
import java.io.IOException; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class TwitchGlobalBadge extends StreamEmote { | ||
private static final Pattern idPattern = Pattern.compile("https://static-cdn.jtvnw.net/badges/v1/([\\da-f-]+)/\\d"); | ||
public final String id; | ||
public final ChatBadgeSet set; | ||
public final ChatBadge badge; | ||
|
||
public TwitchGlobalBadge(ChatBadge badge, ChatBadgeSet set) throws IOException { | ||
super(Type.TWITCH_GLOBAL_BADGE, getBadgeId(badge), "streamchatmod/emotes/twitch_global_badges/" + getBadgeId(badge) + "_3x.png", set.getSetId() + ":" + badge.getId(), false); | ||
this.badge = badge; | ||
this.set = set; | ||
this.id = getBadgeId(badge); | ||
} | ||
|
||
public static String getBadgeId(ChatBadge badge) { | ||
Matcher m = idPattern.matcher(badge.getSmallImageUrl()); | ||
return m.find() ? m.group(1) : null; | ||
} | ||
} |