miggor-StreamGraph/classes/deck/nodes/twitch/twitch_send_chat.gd
Eroax 2d5fcd25f6 Reworks Twitch Nodes to work with the new Triggers Workflow. (#82)
Closes #59 by reworking Twitch Nodes to use the new Trigger workflow that allows inputs that trigger through Ports with Port.UsageType.BOTH as well the functionality for Port.UsageType.VALUE_REQUEST and Port.UsageType.TRIGGER.

Co-authored-by: Eroax <eroaxebusiness@duck>
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/82
2024-02-26 11:36:19 +00:00

79 lines
1.3 KiB
GDScript

# (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
enum inputs {
message,
channel,
send
}
func _init():
name = "Twitch Send Chat"
node_type = "twitch_send_chat"
description = "Sends a message to a Twitch chat."
add_input_port(
DeckType.Types.STRING,
"Message",
"field"
)
add_input_port(
DeckType.Types.STRING,
"Channel",
"field"
)
add_input_port(
DeckType.Types.BOOL,
"Send",
"button"
)
func _receive(to_input_port, data: Variant):
data = str(data)
var message
var channel
match to_input_port:
inputs.message:
message = data
channel = await resolve_input_port_value_async(inputs.channel)
inputs.channel:
channel = data
message = await resolve_input_port_value_async(inputs.message)
inputs.send:
channel = await resolve_input_port_value_async(inputs.channel)
message = await resolve_input_port_value_async(inputs.message)
if channel == null:
channel = ""
if message == null:
return
if message.is_empty():
DeckHolder.logger.log_node("Twitch Send Chat: Port %d: Supplied message was empty." % [to_input_port])
Connections.twitch.send_chat(message, channel)