Giter VIP home page Giter VIP logo

unity-twitch-chat's Introduction

Unity Twitch Chat

This is a lightweight and efficient Twitch.tv IRC client for Unity.
The primary goal is to be able to read and send chat messages as efficiently as possible.

In short, this allows you to integrate Twitch Chat to your Unity projects.

Chat message example

Supported features

  • Reading and sending chat messages
  • Parsing Twitch emotes and badges
  • Optional anonymous login
  • Automatic ratelimit checks

Unsupported features

  • Special messages (whispers, sub/resub, raids, first time viewers, etc)
  • Bits cheering, channel points, predictions, etc
  • Moderation (ban, timeout, etc)
  • Third party extensions (FFZ, BTTV, 7TV, etc)
  • and more...

Other limitations

  • WebGL builds are not supported

Installation

  • Open Unity Package Manager (Window -> Package Manager)
  • Click the + button in the top left corner
  • Select Add package from git URL...
  • Copy and paste the following URL:
https://github.com/lexonegit/Unity-Twitch-Chat.git?path=/Unity-Twitch-Chat/Assets/Package
  • Install by clicking Add

Quick start

  1. Install the Unity package (see above)
  2. Create a new empty GameObject and add the TwitchIRC 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.OnMessageReceived event. The listener will receive Chatter objects which contain information about the 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.Ping() -> Sends a PING message to the Twitch IRC server
  • IRC.OnMessageReceived -> 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

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

License

MIT License

Projects made with Unity Twitch Chat

Intro Fighters, stream overlay game https://lexone.itch.io/introfighters

Did you make something cool? Contact me (Lexone#3407) to get featured here!

unity-twitch-chat's People

Contributors

drrnb avatar joshgrrro avatar lexonegit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.