From cdd8b6980f1da350d0a2f00f064dccc15c839cc3 Mon Sep 17 00:00:00 2001 From: lexonegit Date: Thu, 22 Aug 2024 15:34:50 +0300 Subject: [PATCH] Update README --- README.md | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 26e382f..12cf428 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ In short, this allows you to integrate Twitch Chat to your Unity projects.
Th - Parsing Twitch emotes and badges - Optional anonymous login - Automatic ratelimit checks +- Name color normalization (similar to native Twitch chat) ### Unsupported features - Special messages (whispers, sub/resub, raids, first time viewers, etc) @@ -39,36 +40,39 @@ https://github.com/lexonegit/Unity-Twitch-Chat.git?path=/Unity-Twitch-Chat/Asset ## Quick start 1. Install the Unity package (see above) 2. Create a new empty GameObject and add the `Twitch IRC` component. -3. In the inspector, set your Twitch authentication details (OAuth, username, channel) -You can generate an OAuth token at https://twitchapps.com/tmi/ -OAuth and username are not needed if `Use Anonymous Login` is enabled. -4. Make sure `Connect On Start` is enabled and press play – You should now see JOIN messages, etc. in the console. -5. To start handling chat messages, add a listener to the `IRC.OnChatMessage` event. The listener will receive `Chatter` objects which contain information about the chat message, such as the chatter name, message, emotes, etc... +3. In the inspector, set your Twitch details (OAuth, username, channel) + - You can generate an OAuth token at https://twitchapps.com/tmi/ + - Alternatively you can enable `Use Anonymous Login` to use without OAuth +4. Make sure `Connect IRC On Start` and `Join Channel On Start` are enabled and press play – You should now see JOIN messages, etc. in the console. +5. Create a new script that has a listener for the `IRC.OnChatMessage` event. + - See ListenerExample.cs for reference. + - The listener will receive `Chatter` objects which contain information about each chat message, such as the chatter name, message, emotes, etc... Having issues? Check out the included ExampleProject for a better understanding. ## Example project Spawn chatters as jumping boxes. Box color is based on their primary badge. + ## API documentation ### IRC.cs -- **IRC.Connect()** -> Connects to Twitch IRC -- **IRC.Disconnect()** - Disconnects from Twitch IRC -- **IRC.SendChatMessage(string message)** -> Sends a chat message to the channel -- **IRC.JoinChannel(string channel)** -> Join a Twitch channel -- **IRC.LeaveChannel(string channel)** -> Leave a Twitch channel -- **IRC.Ping()** -> Sends a PING message to the Twitch IRC server -- **IRC.OnChatMessage** -> Event that is invoked when a chat message is received -- **IRC.OnConnectionAlert** -> Event that is invoked when a connection alert is received -- **IRC.ClientUserTags** -> The tags (badges, name color, etc) of the client user +- `void` **Connect()** - Connects to Twitch IRC +- `void` **Disconnect()** - Disconnects from Twitch IRC +- `void` **SendChatMessage(string message)** - Sends a chat message to the channel +- `void` **JoinChannel(string channel)** - Join a Twitch channel +- `void` **LeaveChannel(string channel)** - Leave a Twitch channel +- `void` **Ping()** - Sends a PING message to the Twitch IRC server +- `event` **OnChatMessage** - Event that is invoked when a chat message is received +- `event` **OnConnectionAlert** - Event that is invoked when a connection alert is received +- `IRCTags` **ClientUserTags** - Returns the tags of the client user (badges, name color, etc) ### Chatter.cs -- **Chatter.GetNameColor()** -> Returns the color of the chatter's name -- **Chatter.IsDisplayNameFontSafe()** -> Returns true if displayName is "font-safe" meaning that it only contains characters: a-z, A-Z, 0-9, _ -- **Chatter.ContainsEmote(string emoteId)** -> Returns true if the chatter's message contains the specified emote (by id) -- **Chatter.HasBadge(string badgeName)** -> Returns true if the chatter has the specified badge +- `Color` **GetNameColor()** - Returns the color of the chatter's name +- `bool` **IsDisplayNameFontSafe()** - Returns true if displayName is "font-safe" meaning that it only contains characters: a-z, A-Z, 0-9, _ +- `bool` **ContainsEmote(string emoteId)** - Returns true if the chatter's message contains the specified emote (by id) +- `bool` **HasBadge(string badgeName)** - Returns true if the chatter has the specified badge ## License MIT License @@ -77,4 +81,4 @@ Spawn chatters as jumping boxes. Box color is based on their primary badge. Intro Fighters, stream overlay game https://lexone.itch.io/introfighters -*Did you make something cool? Contact me (Lexone#3407) to get featured here!* +*Did you make something cool? Contact me (lexone on Discord) to get featured here!*