Red-DiscordBot
Red-DiscordBot copied to clipboard
[Streams] Game allow list for stream alerts
Type
- [ ] Bugfix
- [x] Enhancement
- [ ] New feature
Description of the changes
Game filter for stream alerts. Should ultimately support Twitch and Smashcast unless anything has changed with regards to the idea in Youtube or Picarto's APIs. Replacement for #2433, fixes #2356 and #3654
Quick look at api docs to refresh myself tells me that Youtube is a definite no. Picarto actually does have categories (which are given as a string when retrieving a stream but have more data beyond that if grabbing the list of categories and thus the category name can be validated) that could be used to filter but this assumes that is something that can change from stream to stream, which I'm ultimately not sure on simply because I'm not at all familiar with Picarto. If anyone happens to have insight into this, feel free to let me know
Twitch and Smashcast support have been implemented. Haven't touched Picarto for the reasons I mentioned in https://github.com/Cog-Creators/Red-DiscordBot/pull/4174#issuecomment-671114687
Otherwise, this needs testing (I haven't really done much testing of this myself)
So to start after a full day of testing...
-
twitch: it works fine and all commands works. but when adding a game for the specified channel it does not send alert.
-
smashcast: i got into an issue by using
streamalert smashcast addgame <channel_name> <game_name>.
Traceback (most recent call last):
File "/home/aina/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/aina/redenv/lib/python3.8/site-packages/redbot/cogs/streams/streams.py", line 418, in smashcast_addgame
async with aiohttp.ClientSession as session:
AttributeError: __aexit__
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/aina/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/home/aina/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 825, in invoke
await super().invoke(ctx)
File "/home/aina/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1307, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/aina/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 825, in invoke
await super().invoke(ctx)
File "/home/aina/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1307, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/aina/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/aina/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: __aexit__
The issue with [p]streamalert smashcast addgame should be fixed now
The issue with
[p]streamalert smashcast addgameshould be fixed now
i'm getting it with [p]streamalert smashcast removegame too.
Exception in command 'streamalert smashcast removegame'
Traceback (most recent call last):
File "/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/redenv/lib/python3.8/site-packages/redbot/cogs/streams/streams.py", line 485, in smashcast_removegame
async with aiohttp.ClientSession as session:
AttributeError: __aexit__
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 825, in invoke
await super().invoke(ctx)
File "/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1307, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 825, in invoke
await super().invoke(ctx)
File "/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1307, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: __aexit__
yeah, that would be the result of copying and pasting and changing what needed to be changed lol
Which is now fixed
So, testing have been done, no more issues found, and it sends the correct game from twitch and smashcast. it just takes longer to get notified than i though, about 3 - 5 minutes to wait, but other than that, it works great, i really like this.
also, just to leave about this:
Multiple possible options found. Please enter the number of the one you were trying to add.
<generator object pagify at 0x7f26a9491f20>
generator object pagify. it shows when you addgame and removegame on smashcast alerts, which i found a bit confused, so not sure if it should be like that.
also, just to leave about this:
Multiple possible options found. Please enter the number of the one you were trying to add. <generator object pagify at 0x7f26a9491f20>
generator object pagify. it shows when youaddgameandremovegameon smashcast alerts, which i found a bit confused, so not sure if it should be like that.
yeah, that would be a bug
Twitch and Smashcast support have been implemented. Haven't touched Picarto for the reasons I mentioned in #4174 (comment)
@palmtree5 So to move forward with this, we need a decision for Picarto?
It seems like the categories (called communities on their site) aren't as specific when it comes to games, but I think Picarto is focusing more on creative work and so there are more specific categories related to that. I think it would probably be useful for Picarto users, but I wouldn't say it's that important for Red to support them until we get a feature request for it. But if you do want to spend time to write it even though it might not really be used, I would say go for it.
Twitch and Smashcast support have been implemented. Haven't touched Picarto for the reasons I mentioned in #4174 (comment)
@palmtree5 So to move forward with this, we need a decision for Picarto?
It seems like the categories (called communities on their site) aren't as specific when it comes to games, but I think Picarto is focusing more on creative work and so there are more specific categories related to that. I think it would probably be useful for Picarto users, but I wouldn't say it's that important for Red to support them until we get a feature request for it. But if you do want to spend time to write it even though it might not really be used, I would say go for it.
Yeah, I don't know that it's particularly important to make sure Picarto support is in as the major thing with this (since Mixer died) was Twitch support. I'm honestly not even sure how many people use the Picarto-specific commands. Basically, I agree with waiting on that until someone specifically requests it
Merge conflicts have been resolved for this and the bug @maxbooiii mentioned above has been fixed. Should probably make sure to test this just in case something broke in the process of resolving the merge conflicts though
Merge conflicts have been taken care of, though this will definitely require testing to ensure nothing broke by fixing merge conflicts
I can't get this function to work, and the help menu isn't very straightforward. I tried running
[p]streamalert twitch sp00nd addgame Call of Duty: Black Ops - This is exactly how the game is labeled on Twitch. I have also tried putting it in quotes with the to the same effect.
and I get the same feedback as if I was just running
[p]streamalert twitch sp00nd
Furthermore, [p]streamalert list does not show any game filter, only the Twitch channel and the Discord channel for alerts. What am I missing?
The bot isn't announcing anything at all. Even without a filter. So i'm not sure of the function as it stands.
@sp00nd It's a subcommand. The help should tell you that it's
[p]streamalert twitch addgame <channel_name> <game_name>
@sp00nd It's a subcommand. The help should tell you that it's
[p]streamalert twitch addgame <channel_name> <game_name>
I tried that first, and figured it was wrong as it was spitting back
Error in command 'streamalert twitch addgame'. Check your console or logs for details.
Exception in command 'streamalert twitch addgame'
Traceback (most recent call last):
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/redbot/cogs/streams/streams.py", line 327, in twitch_addgame
game_data = await stream.get_game_info_by_name(game_name)
AttributeError: 'TwitchStream' object has no attribute 'get_game_info_by_name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1348, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1348, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/administrator/.pyenv/versions/red/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'TwitchStream' object has no attribute 'get_game_info_by_name'
yeah, it looks like that function got removed when I fixed merge conflicts. I'll get this fixed
Ok, try updating and then that issue should be fixed
Ok, try updating and then that issue should be fixed
I ran python -m pip install -U --force-reinstall --no-cache git+https://github.com/palmtree5/Red-DiscordBot.git@V3/enhancement/streamalert_gamefilter#egg=Red-DiscordBot in my venv and restarted the bot.
Upon running the command, it is no longer erroring out. However, I am getting Could not find the game requested. Make sure the game name matches how it appears on Twitch. when using several different category names, including ones as simple as "Music". (edit: I have tried quotes on and off, same result.)
How exactly should the game name be when it refers to how it appears on Twitch?
There is no other "appearance" besides the game name itself under the category.
the game name itself under the category
Exactly this. Copy and paste the game name from the game's page on Twitch
the game name itself under the category
Exactly this. Copy and paste the game name from the game's page on Twitch
This is exactly what I have been doing, and it is not recognizing them. Like I mentioned, including ones as simple as "Music"
Is there any way I can provide more logging on this error? I have not been able to get any category working from what i've seen. Used a fresh API key also when troubleshooting this.
I've actually figured out how to go about using IGDB's API to potentially just allow a search of their API for the user's desired game, which would potentially allow the user to do something like [p]streamalert twitch addgame <channel_name> zelda, which would then call out to IGDB's API to search, returning the list to the user to select a game from and then use the game's IGDB id to then get the game's data from Twitch (since the ID in the /helix/streams endpoint is not the game's IGDB ID, we still need to get Twitch's ID for the game the user selected). This seems like it could be a little more user-friendly in some ways than making the user copy and paste the name from the game's directory page on Twitch
Is there an opportunity anywhere in here to add support for filtering by words in stream title and by tags as well?
More context: https://github.com/Cog-Creators/Red-DiscordBot/issues/2356#issuecomment-2200683328