//This gets called whenever a new chat message appears public void NewMessage(TwitchIRC.Chatter newChatter) { Debug.Log("New chatter object received!"); chatter = newChatter; //Examples for using the chatter object: if (chatter.displayName == "Lexone") { Debug.Log("Chat message was sent by Lexone!"); } if (chatter.HasBadge("subscriber")) { Debug.Log("Chat message sender is a subscriber"); } if (chatter.HasBadge("moderator")) { Debug.Log("Chat message sender is a channel moderator"); } if (chatter.MessageContainsEmote("25")) //25 = Kappa emote ID { Debug.Log("Chat message contained the Kappa emote"); } //Etc... }
private IEnumerator SpawnerLoop() { while (true) { yield return(new WaitForSeconds(1f)); if (chatterQueue.Count <= 0) { continue; } TwitchIRC.Chatter chatter = chatterQueue.Dequeue(); GameObject o = Instantiate(boxPrefab, transform.position, Quaternion.identity); string boxName = chatter.displayName; Color boxColor = Color.white; float boxScale = 1f; //Check if chatter is a subscriber, if true make their box color magenta if (chatter.HasBadge("subscriber")) { boxColor = Color.magenta; } //...or if the chatter is a moderator, make the box green! if (chatter.HasBadge("moderator")) { boxColor = Color.green; } //You can see the full list of badge names here: (JSON data) //https://badges.twitch.tv/v1/badges/global/display?language=en //If the chatter's chat message contains the emote Kappa then let's double the size of the box //Kappa emote's ID is = 25 if (chatter.MessageContainsEmote("25")) { boxScale = 2f; } o.GetComponent <Box>().Initialize(boxName, boxColor, boxScale); } }
//This gets called whenever a new chat message appears public void NewMessage(TwitchIRC.Chatter chatter) { chatterQueue.Enqueue(chatter); }