mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
Added twitch_eventsub_event
Handles listening for the given Twitch_Eventsub_Event
This commit is contained in:
parent
b7f6dfe008
commit
5e81a392cd
1 changed files with 41 additions and 0 deletions
41
classes/deck/nodes/twitch/twitch_eventsub_event.gd
Normal file
41
classes/deck/nodes/twitch/twitch_eventsub_event.gd
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# (c) 2023-present Eroax
|
||||||
|
# (c) 2023-present Yagich
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
extends DeckNode
|
||||||
|
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
name = "Twitch EventSub Event"
|
||||||
|
node_type = name.to_snake_case()
|
||||||
|
description = "Listens for a specific Event from Twitch EventSub"
|
||||||
|
|
||||||
|
props_to_serialize = []
|
||||||
|
|
||||||
|
# Adds a port that allows specifying what type of event to listen for.
|
||||||
|
add_input_port(DeckType.Types.STRING, "Event Name", "field")
|
||||||
|
# Adds a port that outputs when the Event has been received
|
||||||
|
add_output_port(DeckType.Types.ANY, "Event Received")
|
||||||
|
# Adds a port that outputs the data received when the Event has been received.
|
||||||
|
add_output_port(DeckType.Types.DICTIONARY, "Event Data")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _event_received(event_name: StringName, event_data: Dictionary = {}):
|
||||||
|
|
||||||
|
if event_name != &"twitch_eventsub":
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
var port_0 = await resolve_input_port_value_async(0)
|
||||||
|
if port_0 == null or port_0 != event_data.payload.subscription.type:
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
# Sends to indicate that the specified event has happened.
|
||||||
|
send(0, null)
|
||||||
|
# Sends the data along as well as the fact that the event happened
|
||||||
|
send(1, event_data)
|
||||||
|
|
Loading…
Reference in a new issue