Skip to content

Commit b3ee2e3

Browse files
committed
Get self correct colour
1 parent a707900 commit b3ee2e3

File tree

1 file changed

+16
-1
lines changed
  • src/main/java/eu/pabl/twitchchat/twitch_integration

1 file changed

+16
-1
lines changed

src/main/java/eu/pabl/twitchchat/twitch_integration/Bot.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,22 @@ public void onMessage(MessageEvent event) throws Exception {
117117

118118
@Override
119119
public void onUnknown(UnknownEvent event) throws Exception {
120-
System.out.println("UNKNOWN TWITCH EVENT: " + event.toString());
120+
switch (event.getCommand()) {
121+
case "USERSTATE" -> {
122+
// Info about our user. More at https://dev.twitch.tv/docs/irc/commands/#userstate
123+
// Set our correct colour :).
124+
String colorTag = event.getTags().get("color");
125+
if (colorTag != null) {
126+
Color userColor = Color.decode(colorTag);
127+
TextColor formattingColor = TextColor.fromRgb(userColor.getRGB());
128+
129+
putFormattingColor(getUsername(), formattingColor);
130+
}
131+
}
132+
default -> {
133+
System.out.println("UNKNOWN TWITCH EVENT: " + event.toString());
134+
}
135+
}
121136
}
122137

123138
@Override

0 commit comments

Comments
 (0)