mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Streams] Add ability to exclude rerun streams from alerts (#2620)
* [Streams] Add ability to exclude rerun streams from alerts * [Docs] Changelog entries for contributions by EgonSpengler * Changelog entry for #2620 [Streams] Ignore Reruns In Alerts
This commit is contained in:
parent
7e49ce9a7b
commit
f28d6dff32
@ -63,6 +63,7 @@ Mod
|
|||||||
---
|
---
|
||||||
|
|
||||||
* Admins can now decide how many times message has to be repeated before ``deleterepeats`` removes it (`#2437`_)
|
* Admins can now decide how many times message has to be repeated before ``deleterepeats`` removes it (`#2437`_)
|
||||||
|
* Fix: make ``[p]ban [days]`` optional as per the doc (`#2602`_)
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
Setup Scripts
|
Setup Scripts
|
||||||
@ -72,6 +73,13 @@ Setup Scripts
|
|||||||
* ``redbot-setup convert`` now used to convert between libraries (`#2579`_)
|
* ``redbot-setup convert`` now used to convert between libraries (`#2579`_)
|
||||||
* Backup support for Mongo is currently broken (`#2579`_)
|
* Backup support for Mongo is currently broken (`#2579`_)
|
||||||
|
|
||||||
|
-------
|
||||||
|
Streams
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Add support for custom stream alert messages per guild (`#2600`_)
|
||||||
|
* Add ability to exclude rerun Twitch streams, and note rerun streams in embed status (`#2620`_)
|
||||||
|
|
||||||
-----
|
-----
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
@ -125,5 +133,8 @@ Utility Functions
|
|||||||
.. _#2591: https://github.com/Cog-Creators/Red-DiscordBot/pull/2591
|
.. _#2591: https://github.com/Cog-Creators/Red-DiscordBot/pull/2591
|
||||||
.. _#2592: https://github.com/Cog-Creators/Red-DiscordBot/pull/2592
|
.. _#2592: https://github.com/Cog-Creators/Red-DiscordBot/pull/2592
|
||||||
.. _#2595: https://github.com/Cog-Creators/Red-DiscordBot/pull/2595
|
.. _#2595: https://github.com/Cog-Creators/Red-DiscordBot/pull/2595
|
||||||
|
.. _#2600: https://github.com/Cog-Creators/Red-DiscordBot/pull/2600
|
||||||
|
.. _#2602: https://github.com/Cog-Creators/Red-DiscordBot/pull/2602
|
||||||
.. _#2604: https://github.com/Cog-Creators/Red-DiscordBot/pull/2604
|
.. _#2604: https://github.com/Cog-Creators/Red-DiscordBot/pull/2604
|
||||||
.. _#2606: https://github.com/Cog-Creators/Red-DiscordBot/pull/2606
|
.. _#2606: https://github.com/Cog-Creators/Red-DiscordBot/pull/2606
|
||||||
|
.. _#2620: https://github.com/Cog-Creators/Red-DiscordBot/pull/2620
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class Streams(commands.Cog):
|
|||||||
"mention_here": False,
|
"mention_here": False,
|
||||||
"live_message_mention": False,
|
"live_message_mention": False,
|
||||||
"live_message_nomention": False,
|
"live_message_nomention": False,
|
||||||
|
"ignore_reruns": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
role_defaults = {"mention": False}
|
role_defaults = {"mention": False}
|
||||||
@ -461,6 +462,19 @@ class Streams(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
await ctx.send(_("Notifications will no longer be deleted."))
|
await ctx.send(_("Notifications will no longer be deleted."))
|
||||||
|
|
||||||
|
@streamset.command(name="ignorereruns")
|
||||||
|
@commands.guild_only()
|
||||||
|
async def ignore_reruns(self, ctx: commands.Context):
|
||||||
|
"""Toggle excluding rerun streams from alerts."""
|
||||||
|
guild = ctx.guild
|
||||||
|
current_setting = await self.db.guild(guild).ignore_reruns()
|
||||||
|
if current_setting:
|
||||||
|
await self.db.guild(guild).ignore_reruns.set(False)
|
||||||
|
await ctx.send(_("Streams of type 'rerun' will be included in alerts."))
|
||||||
|
else:
|
||||||
|
await self.db.guild(guild).ignore_reruns.set(True)
|
||||||
|
await ctx.send(_("Streams of type 'rerun' will no longer send an alert."))
|
||||||
|
|
||||||
async def add_or_remove(self, ctx: commands.Context, stream):
|
async def add_or_remove(self, ctx: commands.Context, stream):
|
||||||
if ctx.channel.id not in stream.channels:
|
if ctx.channel.id not in stream.channels:
|
||||||
stream.channels.append(ctx.channel.id)
|
stream.channels.append(ctx.channel.id)
|
||||||
@ -524,7 +538,7 @@ class Streams(commands.Cog):
|
|||||||
for stream in self.streams:
|
for stream in self.streams:
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
try:
|
try:
|
||||||
embed = await stream.is_online()
|
embed, is_rerun = await stream.is_online()
|
||||||
except OfflineStream:
|
except OfflineStream:
|
||||||
if not stream._messages_cache:
|
if not stream._messages_cache:
|
||||||
continue
|
continue
|
||||||
@ -540,6 +554,9 @@ class Streams(commands.Cog):
|
|||||||
continue
|
continue
|
||||||
for channel_id in stream.channels:
|
for channel_id in stream.channels:
|
||||||
channel = self.bot.get_channel(channel_id)
|
channel = self.bot.get_channel(channel_id)
|
||||||
|
ignore_reruns = await self.db.guild(channel.guild).ignore_reruns()
|
||||||
|
if ignore_reruns and is_rerun:
|
||||||
|
continue
|
||||||
mention_str, edited_roles = await self._get_mention_str(channel.guild)
|
mention_str, edited_roles = await self._get_mention_str(channel.guild)
|
||||||
|
|
||||||
if mention_str:
|
if mention_str:
|
||||||
|
|||||||
@ -174,7 +174,8 @@ class TwitchStream(Stream):
|
|||||||
# self.already_online = True
|
# self.already_online = True
|
||||||
# In case of rename
|
# In case of rename
|
||||||
self.name = data["stream"]["channel"]["name"]
|
self.name = data["stream"]["channel"]["name"]
|
||||||
return self.make_embed(data)
|
is_rerun = True if data["stream"]["stream_type"] == "rerun" else False
|
||||||
|
return self.make_embed(data), is_rerun
|
||||||
elif r.status == 400:
|
elif r.status == 400:
|
||||||
raise InvalidTwitchCredentials()
|
raise InvalidTwitchCredentials()
|
||||||
elif r.status == 404:
|
elif r.status == 404:
|
||||||
@ -204,6 +205,7 @@ class TwitchStream(Stream):
|
|||||||
|
|
||||||
def make_embed(self, data):
|
def make_embed(self, data):
|
||||||
channel = data["stream"]["channel"]
|
channel = data["stream"]["channel"]
|
||||||
|
is_rerun = data["stream"]["stream_type"] == "rerun"
|
||||||
url = channel["url"]
|
url = channel["url"]
|
||||||
logo = channel["logo"]
|
logo = channel["logo"]
|
||||||
if logo is None:
|
if logo is None:
|
||||||
@ -211,6 +213,8 @@ class TwitchStream(Stream):
|
|||||||
status = channel["status"]
|
status = channel["status"]
|
||||||
if not status:
|
if not status:
|
||||||
status = "Untitled broadcast"
|
status = "Untitled broadcast"
|
||||||
|
if is_rerun:
|
||||||
|
status += " - Rerun"
|
||||||
embed = discord.Embed(title=status, url=url)
|
embed = discord.Embed(title=status, url=url)
|
||||||
embed.set_author(name=channel["display_name"])
|
embed.set_author(name=channel["display_name"])
|
||||||
embed.add_field(name="Followers", value=channel["followers"])
|
embed.add_field(name="Followers", value=channel["followers"])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user