miggor-StreamGraph/classes/connections/connections.gd
Eroax f98364f40e Add in General EventSub Nodes (#65)
Adds in these nodes:
- Twitch Add EventSub Subscription
- Twitch EventSub Event

Co-authored-by: Eroax <eroaxe.business@gmail.com>
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/65
Co-authored-by: Eroax <eroax@noreply.codeberg.org>
Co-committed-by: Eroax <eroax@noreply.codeberg.org>
2024-02-09 11:43:17 +00:00

52 lines
1.4 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)
class_name Connections
static var obs_websocket
static var twitch
static func _twitch_eventsub_event_received(event_data : Dictionary):
DeckHolder.send_event(&"twitch_eventsub", event_data)
static func _twitch_chat_received(msg_dict : Dictionary):
DeckHolder.send_event(&"twitch_chat", msg_dict)
## Temporary Function for loading generic Connection credentials from user:// as a [CredSaver] Resource
static func load_credentials(service : String):
if !FileAccess.file_exists("user://" + service + "_creds.res"):
DeckHolder.logger.log_system("No Credentials exist for " + service + " Service", Logger.LogType.WARN)
return null
var creds = ResourceLoader.load("user://" + service + "_creds.res")
if !creds is CredSaver:
DeckHolder.logger.log_system("Error loading Credentials for " + service + " Service", Logger.LogType.ERROR)
return null
return creds
## Temporary function for saving generic Connection credentials to user:// as a CredSaver
static func save_credentials(data : Dictionary, service: String):
var creds := CredSaver.new()
creds.data = data
var err = ResourceSaver.save(creds, "user://" + service + "_creds.res")
if err != OK:
DeckHolder.logger.log_system("Error saving Credentials for " + service + " Service", Logger.LogType.ERROR)