General NoTwitch EventSub Update

This commit is contained in:
Eroax 2024-01-26 03:28:35 -07:00
parent c1a91b9a6a
commit 5fed9566c6
2 changed files with 18 additions and 3 deletions

View file

@ -33,7 +33,12 @@ func connect_to_eventsub(events : Array[Twitch_Connection.EventSub_Subscription]
for all in events:
responses.append(connection.add_eventsub_subscription(all))
responses.append(await connection.add_eventsub_subscription(all))
if responses.size() == 1:
return responses[0]
return responses

View file

@ -105,6 +105,16 @@ func setup_eventsub_connection(events : Array[EventSub_Subscription] = [], timeo
func add_eventsub_subscription(sub_type : EventSub_Subscription):
if eventsub_socket == null:
return await setup_eventsub_connection([sub_type])
if sub_type.session_id == "":
sub_type.session_id = eventsub_socket.session_id
return twitch_request("https://api.twitch.tv/helix/eventsub/subscriptions", HTTPClient.METHOD_POST, str(sub_type.return_request_dictionary()))
@ -116,7 +126,7 @@ func subscribe_to_channel_points(user_id : String):
return
return add_eventsub_subscription(EventSub_Subscription.new("channel.channel_points_custom_reward_redemption.add", {"broadcaster_user_id" : user_id}, eventsub_socket.session_id))
return await add_eventsub_subscription(EventSub_Subscription.new("channel.channel_points_custom_reward_redemption.add", {"broadcaster_user_id" : user_id}, eventsub_socket.session_id))
func _process(delta):
@ -324,7 +334,7 @@ class EventSub_Subscription:
var method = "websocket"
func _init(sub_type : String, cond : Dictionary, sess_id : String, vers : String = "1"):
func _init(sub_type : String, cond : Dictionary, sess_id : String = "", vers : String = "1"):
subscription_type = sub_type
version = vers