2023-12-15 22:44:25 +01:00
|
|
|
# (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
|
|
|
|
|
2024-02-26 12:36:19 +01:00
|
|
|
enum inputs {
|
|
|
|
|
|
|
|
message,
|
|
|
|
channel,
|
|
|
|
send
|
|
|
|
|
|
|
|
}
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
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(
|
2024-03-06 08:50:23 +01:00
|
|
|
DeckType.Types.ANY,
|
2023-12-15 22:44:25 +01:00
|
|
|
"Send",
|
2024-03-06 08:50:23 +01:00
|
|
|
"button",
|
|
|
|
Port.UsageType.TRIGGER,
|
|
|
|
).button_pressed.connect(_receive.bind(inputs.send, null))
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
|
2024-03-06 08:50:23 +01:00
|
|
|
func _receive(to_input_port: int, data: Variant) -> void:
|
2023-12-15 22:44:25 +01:00
|
|
|
|
2024-02-26 12:36:19 +01:00
|
|
|
data = str(data)
|
|
|
|
|
|
|
|
var message
|
|
|
|
var channel
|
|
|
|
match to_input_port:
|
2023-12-15 22:44:25 +01:00
|
|
|
|
2024-02-26 12:36:19 +01:00
|
|
|
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)
|
|
|
|
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
if channel == null:
|
|
|
|
|
|
|
|
channel = ""
|
|
|
|
|
2024-02-26 12:36:19 +01:00
|
|
|
if message == null:
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
return
|
2024-02-26 12:36:19 +01:00
|
|
|
|
|
|
|
if message.is_empty():
|
2023-12-15 22:44:25 +01:00
|
|
|
|
2024-02-26 12:36:19 +01:00
|
|
|
DeckHolder.logger.log_node("Twitch Send Chat: Port %d: Supplied message was empty." % [to_input_port])
|
|
|
|
|
|
|
|
|
|
|
|
Connections.twitch.send_chat(message, channel)
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
|