Giter Club home page Giter Club logo

gift's People

Contributors

aaronfranke avatar digital-mint-creature avatar gigaforge avatar haskaris avatar issork avatar joelcreatesgames avatar jynus avatar nogre avatar yagich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gift's Issues

Emitters not emitting?

First of all this is awesome! I've got it mostly working though I don't really know how the emotes are suppose to work.

The issue I'm having is the signals. I've been searching through the code but can't seem to find if there was some sort of emitter on off code. If I build my own emitters they work, but I can't tap into the ones already in the code. I try connecting to them but they never seem to fire. Any suggestions?

HTTPClient polled multiple times

I am trying to use the library and that it comes by default exporting to html5 with godot 3.5, but when I receive a chat message, it goes into a loop with the following error:

tmp_js_export.js:369 WARNING: HTTPClient polled multiple times in one frame, but request cannot progress more than once per frame on the HTML5 platform.

tmp_js_export.js:369 at: poll (platform/javascript/http_client_javascript.cpp:270) - HTTPClient polled multiple times in one frame, but request cannot progress more than once per frame on the HTML5 platform.

and from there everything stops working.

hangs at connnecting to twitch IRC

This works on 4.0.0 but not the latest version. It gets hung at,
"Token verified.
Connecting to Twitch IRC."

It doesn't give me any errors or tell me anything else unfortunately. I am going to try a fresh install and delete this if the issue is on my end.

Is there a reason why the refresh token is not used?

Hi,
just went through the code and saw that it is using the Authorization code grant flow for authenticating with twitch, which is great!
But I am not sure, if I miss something here.

Your code checks, if the access token is still valid and if it isn't a signal is called but as far as I see, it does not try to get a new token by using the refresh token you got on authorization.

The authorize function also will always just newly authenticate to get an access token. If the file already exists (which should also include a refresh token) it could simply refresh the token, so the user does not have to open the browser everytime the game is started.

My take on this would be:

authorize function:

  • if the auth/user_token file exists check if there is an refresh token also. If so try refreshing.
  • if the file does not exist, can not be opened, or does not include a refresh token do the stuff the function does normally.

expired_token_check:

  • if the token expired check for the refresh token and if it exists refresh the token and save the new one. Then restart the websocket connection
  • else keep the existing signal and tell the user he has to connect again.

Comands with arguments are not working

on function handle_message, message.split maxsplit should be 4 not 3:
var msg : PoolStringArray = message.split(" ", true, 4)

otherwise msg[3] will not be reconized as a comand, and msg[4] wont exist.

Resumed function 'start()' after yield, but script is gone.

E 0:15:12.072   resume: Resumed function 'start()' after yield, but script is gone. At script: res://addons/gift/util/image_cache.gd:65
  <C++ Error>   Method failed. Returning: Variant()
  <C++ Source>  modules/gdscript/gdscript_function.cpp:1795 @ resume()

I added "pass" after the yield to eliminate this error. Is this the best thing to do?

Enabling disk_cache can lead to an exception (invalid_index) when changing channel

I did the following:

  • Enabled disk_cache
  • Connected and read some events from one Twitch channel
  • Disconnected/closed my application
  • Connected to a different channel

I got the following error:

Invalid get index 'badge_sets' (on base 'Dictionary'). (gift_node.gd:525)
Screenshot_20230805_175123

I guessed that it assumes that if the cache exists, it contains this key. I fixed the issue by changing the logic to this:

		if (disk_cache && FileAccess.file_exists(filename)):
			var cache = JSON.parse_string(FileAccess.get_file_as_string(filename))
			if "badge_sets" in cache:
				return cache["badge_sets"]

		var request : HTTPRequest = HTTPRequest.new()
		add_child(request)
		request.request("https://api.twitch.tv/helix/chat/badges" + ("/global" if channel_id == "_global" else "?broadcaster_id=" + channel_id), [USER_AGENT, "Authorization: Bearer " + token["access_token"], "Client-Id:" + client_id, "Content-Type: application/json"], HTTPClient.METHOD_GET)

Let me know what you think and I can send you a PR, if it seems like a reasonable change.

ImplicitGrantFlow force opens browser window

In the Example (and from what I can see there is no way to solve this) the ImplicitGranFlow login will always pop open a default browser window for the user to authenticate with Twitch. I'd love to save the access token, refresh token and any other information in order to reload it after the initial page confirmation.

If I'm missing something basic, perhaps the Example, or some other place could make this more clear.

Expected: Only open the browser when access & refresh token is invalid, otherwise just use the prior tokens.

"Invalid Client"

I did the whole procedure, but when I executed the scene it sent me to a page with a dictionary that says:

{
status: 400,
"message": "invalid client"
}

Dictionary key error if invalid secret is used after successful login

I had GIFT up and running. Great add-on, thanks for all your work!

I accidentally committed my secret to my repo (despite making an auth file to avoid that ๐Ÿ˜’) so I created a new secret at dev.twitch.tv and updated the secret in the auth file.

Now attempting to connect I receive a 403: Invalid client secret response and the add-on crashes at line 174 in gift_node.gd.

image

Godot 4.0 support?

Hey, great add-on. Is this compatible with Godot 4.0? If not, are you planning on updating it?

Thanks.

Send commands as whisper

Hey, I'm using your addon to create interactive overlays with Godot, and first of all I want to thank you for your work!

I would the viewers to be able to send commands but as whisper instead of a chat message. This would allow the chat to not be flooded with commands, especially when making high interactivity overlays.

Have you thought about that? If you want some help, I could look into it, and make a PR once I have something working.

Regards,
Victor

Hangs on Token Request

I have created the auth.txt file and the Example.tscn pops up my browser to a Twitch redirect at https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=REDACTED&redirect_uri=http://localhost:18297&scope=chat%3Aedit%20chat%3Aread%20moderator%3Aread%3Afollowers which continues to https://twitchtokengenerator.com/?error=redirect_mismatch&error_description=Parameter+redirect_uri+does+not+match+registered+URI, which doesn't look a happy URL.

From here, I can't tell if it's me making a mistake, or something else wrong. The web page asks me if I want to make a bot or custom token as usual. I see no interaction on the page that logs the example project bot in. The print log shows Waiting for user to login. and will go no further.

Apologies if this is a trivial mistake my end, I'm a little stuck at how to proceed.

Invalid get index 'data' on function "connect_to_eventsub"

In file addons/gift/gift_node.gd, on line 454 (last line of the following snippet, function connect_to_eventsub)

add_child(request)
request.request("https://api.twitch.tv/helix/eventsub/subscriptions", ["User-Agent: GIFT/3.0.0 (Godot Engine)", "Authorization: Bearer " + token["access_token"], "Client-Id:" + client_id, "Content-Type: application/json"], HTTPClient.METHOD_POST, JSON.stringify(data))
var reply : Array = await(request.request_completed)
var response : Dictionary = JSON.parse_string(reply[3].get_string_from_utf8())
print("Now listening to %s events for broadcaster_id %s." % [response["data"][0]["type"], response["data"][0]["condition"]["broadcaster_user_id"]])

I get Invalid get index 'data' (on base: 'Dictionary').
The response was to the request was { "error": "Forbidden", "status": 403, "message": "subscription missing proper authorization" }, which does not have the data key, which causes the error.

Also, this code assumes the EventSub subscription process always succeeds, and does not handle any other outcome, which is problematic.

Check if joining a channel is successful (or get a list of channel)

Hello, I have a game and I want the user to input account name, secret and channel for the game to join, and I want to check thoses parameters against invalid parameters, and I didn't see anything about the channel, I'm not really familiar to Twitch and I'm not sure if this is relevant but I don't want the user to just wait for ever, thinking the game is busy joining channel even if it's not.

Broken Asset Store addon

Hey,
I'm trying to use this addon in my 4.2beta2 project but it seems to be broken.

I've set the auth file in my project file to be formatted like required, and I even put all of the info inside of the gift.gd script itself, but it seems to be broken, at least on my Steam Deck, where it just opens a "404 page not found" link to https://id.twitch.tv/oauth2/authorize/`everythingelse`

My application's OAuth Redirect URL is set to http://localhost

Handling a bot that can view events on a different channel (2 different twitch accounts)

So this is more of a request/discussion than a bug, but I was attempting to create a bot that would sit in my channel and have responses as the bot name but also respond to events like point redeems and follows to my channel. It seems like the only way to do this is to have 2 different authentications: one from my twitch, and one from the bot's twitch. The follow notifications worked by having the bot as a moderator, but it seems like other events don't have that functionality.

So I effectively, I set up 2 different scopes and 2 different authorizations. It was kind of a pain, because, since it opens the browser which is logged into my main twitch account, it would automatically authenticate. I ended up having the 2nd one just copy to the clipboard instead of open a browser window from the shell. That way I could paste it into a different browser that was logged into my bot account.

I'm not sure if this is the intended approach -- seems like a real hot mess, but I did get it technically working. Not sure the best way to handle the UX for this due to needing 2 different logins. I guess an "authenticate channel" button and "authenticate bot account" button that would copy the URLs to be pasted in appropriate browser windows?

I just wanted my bot to respond to point redeems! ๐Ÿ˜ญ

Side note, the refresh_tokens() function seems like it might not be entirely correct? Maybe I just don't understand it.

func refresh_token() -> void:
	await(get_tree().create_timer(3600).timeout)
	if (await(is_token_valid(token_user["access_token"])) == ""):
		user_token_invalid.emit()
		return
	else:
		refresh_token()
	var to_remove : Array[String] = []
	for entry in eventsub_messages.keys():
		if (Time.get_ticks_msec() - eventsub_messages[entry] > 600000):
			to_remove.append(entry)
	for n in to_remove:
		eventsub_messages.erase(n)

It seems it waits 1 hour, then, if the token is invalid, it emits a signal and returns. If it's still valid, it calls refresh_token() recursively, which waits 1 hour, etc. So if, after the first hour, the token is invalid, the signal emits (does anything listen to this?) and returns without clearing the eventsub messages (though now that I'm looking at it closer, I guess it only cares about removing old stuff, so maybe that's fine?)

For my thing, I rewrote it like this, but I'm not 100% sure if that's correct, either:

func refresh_token() -> void:
	var tokens_valid := true
	while (tokens_valid):
		await(get_tree().create_timer(3600).timeout)
		if (await(validate_token_and_set_id(token_user["access_token"], ScopeType.SCOPE_TYPE_USER)) == ""):
			tokens_valid = false
		if (await(validate_token_and_set_id(token_channel["access_token"], ScopeType.SCOPE_TYPE_CHANNEL)) == ""):
			tokens_valid = false
		
		if (!tokens_valid):
			user_token_invalid.emit()
			var to_remove : Array[String] = []
			for entry in eventsub_messages.keys():
				if (Time.get_ticks_msec() - eventsub_messages[entry] > 600000):
					to_remove.append(entry)
			for n in to_remove:
				eventsub_messages.erase(n)
			print("TOKENS INVALID!!!!!")

I did eventually run into the token becoming invalid after a few hours, and I'm not sure what to do after that -- just completely reconnect everything? Doesn't look like the original code handles that case either.

I can share more of my code if you'd like, but it's kind of a hot mess...

Chat_message Signal only returns the first word?

I might be dumb but is that on purpose or did I do something wrong?

I connected the chat_message signal, I have the message as a "String" argument and when I print it its only the first word.

User lookup by ID fails

Issue Summary

When attempting to call get_users_by_id(), the call fails with a 400 error. This is due to a bug in the underlying get_users() function, which attempts to get the first ID value from the names array rather than ids, resulting in a request that looks like this:

GET /helix/users/?id=<null>&id=000000000

(where the second id= is the first element in the ids array)

Steps to Reproduce

Create a TwitchAPIConnection and call get_users_by_id() with an array containing at least one valid id.

Expected Behavior

The call should succeed and return information on the user.

Actual Behavior

The call returns an empty response due to a 400 error.

The fix is pretty simple - just change line 92 of api_connection.gd to call ids.pop_back() rather than names.pop_back().

TwitchAPIConnection does not allow you to get_users() without specifying names or ids

According to the Twitch API docs you can get information about the user of your current bearer token if you do a get-users request without specifying specific names or ids to get information about.

For example this allows you to get the username of a user from just the auth bearer token.

However, the get_users function of TwitchAPIConnection immediately returns an empty dictionary if you do not provide either names or ids. Ideally this method should still perform the no param request with just the token to get this information.

I think getting info about the user of the current token is useful and the immediate return if the names and ids arrays are empty should be removed from this function to allow this.

Commands don't work in the chat UI

Currently, commands do not work in the chat UI because Twitch does not send received messages back to the client for processing. Users expect to be able to execute commands, but they can only do so from within the browser.

Sent commands should be processed in the example, to address this confusion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.