Skip to content

Commit

Permalink
fix: special messages can prevent triggering a ChannelMessageEvent
Browse files Browse the repository at this point in the history
:req Invalid CAP command, :tmi.twitch.tv CAP * ACK :, and PING :tmi.twitch.tv


Co-authored-by: Sidd <iProdigy@users.noreply.github.com>
Co-authored-by: SubSide <SubSide@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 18, 2022
1 parent 1c1eac6 commit c81b6a2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions chat/src/main/java/com/github/twitch4j/chat/TwitchChat.java
Expand Up @@ -567,21 +567,21 @@ public void onTextMessage(WebSocket ws, String text) {
// Handle messages
log.trace("Received WebSocketMessage: " + message);
// - CAP
if (message.contains(":req Invalid CAP command")) {
if (message.startsWith(":tmi.twitch.tv 410") || message.startsWith(":tmi.twitch.tv CAP * NAK")) {
log.error("Failed to acquire requested IRC capabilities!");
}
// - CAP ACK
else if (message.contains(":tmi.twitch.tv CAP * ACK :")) {
List<String> capabilities = Arrays.asList(message.replace(":tmi.twitch.tv CAP * ACK :", "").split(" "));
else if (message.startsWith(":tmi.twitch.tv CAP * ACK :")) {
List<String> capabilities = Arrays.asList(message.substring(":tmi.twitch.tv CAP * ACK :".length()).split(" "));
capabilities.forEach(cap -> log.debug("Acquired chat capability: " + cap));
}
// - Ping
else if (message.contains("PING :tmi.twitch.tv")) {
else if (message.equalsIgnoreCase("PING :tmi.twitch.tv")) {
sendTextToWebSocket("PONG :tmi.twitch.tv", true);
log.debug("Responding to PING request!");
}
// - Login failed.
else if (message.equals(":tmi.twitch.tv NOTICE * :Login authentication failed")) {
else if (message.equalsIgnoreCase(":tmi.twitch.tv NOTICE * :Login authentication failed")) {
log.error("Invalid IRC Credentials. Login failed!");
}
// - Parse IRC Message
Expand Down

0 comments on commit c81b6a2

Please sign in to comment.