Updated NoTwitch to allow #50

This commit is contained in:
Eroax 2024-01-21 21:42:11 -07:00
parent 358b55e23c
commit 717b69c35c
2 changed files with 16 additions and 4 deletions

View file

@ -16,7 +16,10 @@ var user_regex := RegEx.new()
var user_pattern := r":([\w]+)!"
func _init():
func _init(owner : Twitch_Connection):
chat_received_rich.connect(owner.check_chat_socket.bind(true))
chat_received.connect(owner.check_chat_socket)
packet_received.connect(data_received)
@ -39,6 +42,8 @@ func connect_to_chat(token, extra = false, nick = "terribletwitch"):
## Handles checking the received packet from [signal Websocket_Client.packet_received]
func data_received(packet : PackedByteArray):

View file

@ -7,6 +7,9 @@ class_name Twitch_Connection
signal token_received(token : String)
signal chat_received(chat_dict)
signal chat_received_rich(chat_dict)
@export var client_id := "qyjg1mtby1ycs5scm1pvctos7yvyc1"
@export var redirect_uri := "http://localhost"
## Port that the redirect_uri will head to on your local system. Defaults to 80 for most cases. Linux tends to prefer 8000 or possibly 1338
@ -66,8 +69,7 @@ func authenticate_with_twitch(scopes : Array[String] = ["chat:read", "chat:edit"
## Sets up the chat connection. Joining 1 room with [param token] as it's "PASS" specifying what account it's on. And the optional [param default_chat] specifying the default room to join. While [param nick] specifies the "nickname" (Not the username on Twitch)
func setup_chat_connection(default_chat : String = "", token : String = token, request_twitch_info = true, nick = "terribletwitch"):
chat_socket = chat_socket_class.new()
chat_socket.chat_received_rich.connect(check_chat_socket)
chat_socket = chat_socket_class.new(self)
# Connects to the Twitch IRC server.
chat_socket.connect_to_chat(token, request_twitch_info)
@ -260,11 +262,16 @@ func check_auth_peer(peer : StreamPeerTCP):
token_received.emit(token)
func check_chat_socket(dict):
func check_chat_socket(dict, rich = false):
prints(dict.user, dict.message)
if rich:
chat_received_rich.emit(dict)
return
chat_received.emit(dict)
## "Promise" Class used for relaying the info received from the supplied [HTTPRequest] node.