Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Streams] Game allow list for stream alerts #4174

Open
wants to merge 24 commits into
base: V3/develop
Choose a base branch
from

Conversation

palmtree5
Copy link
Member

Type

  • Bugfix
  • 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

@palmtree5 palmtree5 added Type: Enhancement Something meant to enhance existing Red features. Work In Progress Category: Cogs - Streams This is related to the Streams cog. labels Aug 9, 2020
@palmtree5
Copy link
Member Author

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

@palmtree5 palmtree5 marked this pull request as ready for review August 11, 2020 04:36
@palmtree5
Copy link
Member Author

Twitch and Smashcast support have been implemented. Haven't touched Picarto for the reasons I mentioned in #4174 (comment)

Otherwise, this needs testing (I haven't really done much testing of this myself)

@ltzmax
Copy link
Contributor

ltzmax commented Aug 24, 2020

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__

@palmtree5
Copy link
Member Author

The issue with [p]streamalert smashcast addgame should be fixed now

@ltzmax
Copy link
Contributor

ltzmax commented Aug 28, 2020

The issue with [p]streamalert smashcast addgame should 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__

@palmtree5
Copy link
Member Author

palmtree5 commented Sep 4, 2020

yeah, that would be the result of copying and pasting and changing what needed to be changed lol

Which is now fixed

@ltzmax
Copy link
Contributor

ltzmax commented Sep 10, 2020

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.

@palmtree5
Copy link
Member Author

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.

yeah, that would be a bug

@Jackenmen Jackenmen added the Type: Feature New feature or request. label Dec 30, 2020
@Jackenmen Jackenmen modified the milestones: 3.4.6, 3.4.7 Jan 17, 2021
@palmtree5
Copy link
Member Author

Merge conflicts have been taken care of, though this will definitely require testing to ensure nothing broke by fixing merge conflicts

@EternalllZM
Copy link

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.

@Twentysix26
Copy link
Member

@sp00nd It's a subcommand. The help should tell you that it's
[p]streamalert twitch addgame <channel_name> <game_name>

@EternalllZM
Copy link

@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'

@palmtree5
Copy link
Member Author

yeah, it looks like that function got removed when I fixed merge conflicts. I'll get this fixed

@palmtree5
Copy link
Member Author

Ok, try updating and then that issue should be fixed

@EternalllZM
Copy link

EternalllZM commented Aug 16, 2021

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.)

@EternalllZM
Copy link

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.

@palmtree5
Copy link
Member Author

the game name itself under the category

Exactly this. Copy and paste the game name from the game's page on Twitch

@EternalllZM
Copy link

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"

@EternalllZM
Copy link

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.

@Jackenmen Jackenmen modified the milestones: 3.4.13, 3.4.x Sep 5, 2021
@palmtree5 palmtree5 modified the milestones: 3.4.x, 3.5.1 Mar 19, 2023
@palmtree5
Copy link
Member Author

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

@Jackenmen Jackenmen modified the milestones: 3.5.6, 3.5.7 Mar 18, 2024
@Jackenmen Jackenmen modified the milestones: 3.5.9, 3.5.10 Apr 20, 2024
@josephrooks
Copy link

Is there an opportunity anywhere in here to add support for filtering by words in stream title and by tags as well?

More context: #2356 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Cogs - Streams This is related to the Streams cog. Type: Feature New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Streams] Add game whitelist
6 participants