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
|
|
|
|
|
|
|
|
var username := ""
|
|
|
|
var message := ""
|
|
|
|
var channel := ""
|
|
|
|
var tags := {}
|
|
|
|
|
|
|
|
|
|
|
|
func _init():
|
|
|
|
name = "Twitch Chat Received"
|
|
|
|
node_type = "twitch_chat_received"
|
|
|
|
description = "Receives Twitch chat events from a Twitch connection."
|
|
|
|
|
|
|
|
add_output_port(
|
2024-03-17 11:28:54 +01:00
|
|
|
DeckType.Types.ANY,
|
|
|
|
"On receive",
|
|
|
|
"",
|
|
|
|
Port.UsageType.TRIGGER,
|
2023-12-15 22:44:25 +01:00
|
|
|
)
|
2024-03-17 11:28:54 +01:00
|
|
|
add_output_port(DeckType.Types.STRING, "Username")
|
|
|
|
add_output_port(DeckType.Types.STRING, "Message")
|
|
|
|
add_output_port(DeckType.Types.STRING, "Channel")
|
|
|
|
add_output_port(DeckType.Types.DICTIONARY, "Tags")
|
|
|
|
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _event_received(event_name : StringName, event_data : Dictionary = {}):
|
2024-02-26 12:36:19 +01:00
|
|
|
|
2023-12-15 22:44:25 +01:00
|
|
|
if event_name != &"twitch_chat":
|
2024-02-26 12:36:19 +01:00
|
|
|
|
2023-12-15 22:44:25 +01:00
|
|
|
return
|
2024-02-26 12:36:19 +01:00
|
|
|
|
2023-12-15 22:44:25 +01:00
|
|
|
username = event_data.username
|
|
|
|
message = event_data.message
|
|
|
|
channel = event_data.channel
|
|
|
|
tags = event_data
|
2024-02-26 12:36:19 +01:00
|
|
|
|
|
|
|
var id = UUID.v4()
|
2024-03-17 11:28:54 +01:00
|
|
|
|
|
|
|
send(0, null, id)
|
|
|
|
send(1, username, id)
|
|
|
|
send(2, message, id)
|
|
|
|
send(3, channel, id)
|
|
|
|
send(4, tags, id)
|
2023-12-15 22:44:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _value_request(on_port: int) -> Variant:
|
|
|
|
match on_port:
|
|
|
|
1:
|
2024-03-17 11:28:54 +01:00
|
|
|
return username
|
2023-12-15 22:44:25 +01:00
|
|
|
2:
|
2024-03-17 11:28:54 +01:00
|
|
|
return message
|
2023-12-15 22:44:25 +01:00
|
|
|
3:
|
2024-03-17 11:28:54 +01:00
|
|
|
return channel
|
|
|
|
4:
|
2023-12-15 22:44:25 +01:00
|
|
|
return tags
|
2024-03-17 11:28:54 +01:00
|
|
|
0, _:
|
2023-12-15 22:44:25 +01:00
|
|
|
return null
|
2024-03-17 11:28:54 +01:00
|
|
|
|