Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
An abstraction layer for Godot Engine to enable interaction with Twitch chat.You can find the legacy versoin (For 2.x) here: https://godotengine.org/asset-library/asset/161History---------* v2.0.0- Backend now uses the newly introduced `WebSocketClient` which makes connection to twitch irc more streightforward and secure using SSL/TLS;- Message emotes are now parsed and can be retrieved (as textures) to be used in the game right away (NOTE: only static `png`/`jpeg` images are supported). TwiCIL supports `Twitch` as well as `BetterTTV` and `FFZ` emotes;- All of the code was refactored so as to use new `GDScript typing` feature introduced in `Godot v3.1`.* v1.3.0- Add your aliases for commands. They become a regular commands with a cloned reaction, so you can manage them as regular commands;- Chat list is now present, so you can track what users join or leave your chat (the corresponding signals are there) .* v1.2.1- Integrated interactive commands.You can now easily add commands for the bot and reaction callbacks to them in a glimpse of a second!
Godot TwiCIL -- Godot Twitch Chat Interaction Layer
Description
An abstraction layer for Godot Engine to enable interaction with twitch chat.
A basic explanation is available in this video (1.5x speed is recomended :D)
TODO:
Implement secure connection over WS for 3.1.x (should have built in tools for the purpose)Add aliases for chat commands- Manage user states (
connected/disconnected/banned users?) - Investigate if it's possible to actively ask server for user list (at least add update of users list on new message)
Implement retrieval of emote images(investigate what can be done to support GIF emotes)
How to use
Assuming you have added TwiCIL node to your scene:
onready var twicil = get_node("TwiCIL")
onready var sprite = get_node("Sprite")
var nick = "MySuperGame"
var client_id = "myClient1D"
var oauth = "oauth:my0auTh"
var channel = "channel_name"
func _setup_twicil():
twicil.connect_to_twitch_chat()
twicil.connect_to_channel(channel, client_id, oauth, nick)
# Connect signals for message and emotes retrieval
twicil.connect("message_recieved", self, "_on_message_recieved")
twicil.connect("emote_recieved", self, "_on_emote_recieved")
# Enable logging (disabled by default)
twicil.set_logging(true)
# Add custom commands to game bot
twicil.commands.add("hi", self, "_command_say_hi", 0)
twicil.commands.add("bye", self, "_command_say_bye_to", 1)
twicil.commands.add("!w", self, "_command_whisper", 0)
# Add some aliases
twicil.commands.add_aliases("hi", ["hello", "hi,", "hello,", "bye"])
# Remove command/alias
twicil.commands.remove("bye")
func _command_say_hi(params):
var sender = params[0]
twicil.send_message(str("Hello, @", sender))
func _command_say_bye_to(params):
var sender = params[0]
var recipient = params[1]
twicil.send_message(str("@", recipient, ", ", sender, " says bye! TwitchUnity"))
func _command_whisper(params):
var sender = params[0]
twicil.send_whisper(sender, "Boo!")
func _ready():
_setup_twicil()
func _on_message_recieved(user_name: String, text: String, emotes: Array) -> void:
twicil.request_emote_from(emotes, user_name, 0)
func _on_emote_recieved(user_name: String, emote: Reference) -> void:
if emote.texture:
sprite.texture = emote.texture
API
Methods
Method | Params | Description |
---|---|---|
connect_to_twitch_chat | -- | Establishes connection to Twitch IRC Chat Server |
connect_to_channel | channel -- channel name to connect to; client_id -- your client_id obtained from Twitch Developer Dashboard; password -- your oauth code obtained from Twitch Developer Dashboard; nickname -- nickname of account your app will be authorized in chat; realname (optional) -- not quite sure if it's necessary, but can be the same as nickname; | Joins specified chat using provided credentials |
set_logging | state -- boolean state | Enable/disable logging communication with server to stdout |
connect_to_host | host -- host IP or FDQN; port -- host port | Establishes connection to specified host:port |
send_command | command -- raw text which is sent | Sends specified command/text directly to the server |
send_message | text -- message text | Sends a regular message to the chat |
send_whisper | recipient -- has to be a valid user name; text -- message text | Whispers (PM) a message to the specified user |
request_emote_from | emotes -- array with emote description dictionaries; user_name -- user name this emote is associated with (is needed to identify emote when it's recieved by emote_recieved signal consumers; index -- the index of emote in the emote array |
Sends a request to one of emotes cache to retrieve an emote |
Signals
Signal | Params | Description |
---|---|---|
message_recieved | sender -- sender nickname; text -- message text; emotes -- array with emote description dictionaries for every emote parsed from the message (Twitch, BetterTTV, FFZ) | Emitted on new messages send to chat |
raw_response_recieved | response -- raw response from Twitch IRC server | Emitted on any response from Twitch IRC server recieved |
user_appeared | user -- user nickname | Emitted on user join notification received from server. NOTE: this has a server delay of several minutes |
user_disappeared | user -- user nickname | Emitted on user part notification received from server. NOTE: this has a server delay of several minutes |
emote_recieved | user -- user nickname the emote is associated with (see request_emote_from ); emote_reference -- an emote reference (one of TwitchEmote, BTTVEmote, FFZEmote) has a texture property of type ImageTexture |
Emitted on user emote retrieval of an emote for a user requested with request_emote_from method |
Manage interactive commands
Method | Params | Description |
---|---|---|
commands. add | chat_command -- command text to react to; target -- target object on which method_name will be invoked; method_name -- method name to be invoked on the target object; params_count=1 -- parameters the command expects to be accepted as valid (optional param, default is 1); variable_params_count=false -- indicates if command can be called with any params count including none (optional param, default is false -- params count is mandatory). NOTE: Params are sent to callback as a list. First list member is ALWAYS sender nickname. See example godot-twicil-example.gd) | Add command text chat_command to trigger method_name on target object and count command valid if params_count amount of params is specified, or call it in any case if variable_params_count is set to true |
commands. add_aliases | chat_command -- command text alias(es) is/are set to; aliases -- a list of aliases to add to reaction of chat_command | Add aliases to chat_command to list of reactions. |
commands. remove | chat_command -- command (or alias) text reaction is set to | Remove command (or alias) from list of reactions |
An abstraction layer for Godot Engine to enable interaction with Twitch chat.
You can find the legacy versoin (For 2.x) here: https://godotengine.org/asset-library/asset/161
History
---------
* v2.0.0
- Backend now uses the newly introduced `WebSocketClient` which makes connection to twitch irc more streightforward and secure using SSL/TLS;
- Message emotes are now parsed and can be retrieved (as textures) to be used in the game right away (NOTE: only static `png`/`jpeg` images are supported). TwiCIL supports `Twitch` as well as `BetterTTV` and `FFZ` emotes;
- All of the code was refactored so as to use new `GDScript typing` feature introduced in `Godot v3.1`.
* v1.3.0
- Add your aliases for commands. They become a regular commands with a cloned reaction, so you can manage them as regular commands;
- Chat list is now present, so you can track what users join or leave your chat (the corresponding signals are there) .
* v1.2.1
- Integrated interactive commands.
You can now easily add commands for the bot and reaction callbacks to them in a glimpse of a second!
Reviews
Quick Information
An abstraction layer for Godot Engine to enable interaction with Twitch chat.You can find the legacy versoin (For 2.x) here: https://godotengine.org/asset-library/asset/161History---------* v2.0.0- Backend now uses the newly introduced `WebSocketClient` which makes connection to twitch irc more streightforward and secure using SSL/TLS;- Message emotes are now parsed and can be retrieved (as textures) to be used in the game right away (NOTE: only static `png`/`jpeg` images are supported). TwiCIL supports `Twitch` as well as `BetterTTV` and `FFZ` emotes;- All of the code was refactored so as to use new `GDScript typing` feature introduced in `Godot v3.1`.* v1.3.0- Add your aliases for commands. They become a regular commands with a cloned reaction, so you can manage them as regular commands;- Chat list is now present, so you can track what users join or leave your chat (the corresponding signals are there) .* v1.2.1- Integrated interactive commands.You can now easily add commands for the bot and reaction callbacks to them in a glimpse of a second!