rothiotome / godot-very-simple-twitch

Very Simple Twitch Chat integration for Godot
MIT License
36 stars 3 forks source link

Last release: 0.0.1 Download in the AssetLib Made for Godot Under MIT license

Logo

Godot Very Simple Twitch

Easily connect your Godot games to Twitch chat. Log in with a single line of code to start reading messages right away. Features two docks for setting up the Twitch developer console and reading chat directly in the editor. Supports OIDC for seamless Twitch API interactions to write messages, timeout users, grant VIP status, and more.

Table of contents

How to install

Godot Very Simple Twitch requires Godot 4.2 or higher. You can check the Godot version you have installed in the bottom dock or your editor.

To verify the installation is correct:

Quick Setup

In order to use Very Simple Twitch, you will need to setup a new App in the Twitch developer console and perform the following steps:

  1. Go to https://dev.twitch.tv/console/apps and authorize Twitch Developer to access your account.

  2. Click on the "Register Your Application" button.

  3. Name your application and set the Category to Game Integration and the OAuth Redirect URL to http://localhost for now.

  4. Set your Client Type to Public

twitch-dev-console-create-app

  1. Click on "Create".

  2. Open the Very Simple Twitch dock in the bottom of your Godot editor.

  3. Copy the Redirect URL addresses from the Twitch Quick Start tab to your Twitch Developer App.

redirect-uri

  1. Copy the generated "Client ID" from your Twitch Developer App and add it to your TwitchOAuth gameobject

client-id

That would be all! Everything is ready to use!

How to Use

How to Login

Simple anonymous connection

This is the easiest way to use the plugin. You can use VerySimpleTwitch.login_chat_anon("channel_name") to connect to the channel without needing a token or any settings customization.

var channel_name: String = "channel_name"

VerySimpleTwitch.login_chat_anon(channel_name)

Get Token and login to channel

You can use VerySimpleTwitch.get_token_and_login_chat() to retrieve the token and automatically login to the twitch chat

VerySimpleTwitch.get_token_and_login_chat()

Note: You will need to set up the CLIENT_ID in the Settings tab and configure the Twitch app accordingly.

How to receive chat messages

To receive the Twitch chat messages, connect the chat_message_received signal from VerySimpleTwitch. The signal contains all the information available from the chatter, including display_name, badges, tags and colors.

func _ready():
    VerySimpleTwitch.chat_message_received.connect(print_chatter_message)

func print_chatter_message(chatter: Chatter):
    print("Message received from %s: %s" % [chatter.tags.display_name, chatter.message])

How to send chat messages

To send chat messages you can use the VerySimpleTwitch.send_chat_message("Hello world") static method. Sending chat messages is only available when you use OAuth connection method with a Token that has writting permissions.

Editor Docks

Godot Very Simple Twitch has two docks. One at the bottom called Very Simple Twitch and one at the right called VSTChatDock. Each is used for a specific function:

VST Chat Dock

As mentioned above, VST Chat Dock is a connection to the Twitch channel chat where all messages are displayed in the editor. This is useful for testing your project as it allows you to easily visualize what and when you are getting the messages.

If you are a Godot streamer, you can read your chat in the same window you are coding in.

Usage

Just add and activate the plugin as explained in the installation instructions, install the plugin as usual and you'll see a new tab in the right dock named "VstChatDock". Type in the name of a channel and click connect. You will see the messages as soon as the plugin connects.

Features

FAQ and Troubleshooting

Change Settings

You can change the Settings in Project > Project Settings > General > Very Simple Twitch. Note that switching on the Advanced Settings toggle will allow you to customize even more your client. Advanced Config are not supposed to be changed without further knowledge on how Twitch works.

License

This project is released under the MIT License by RothioTome (2024)