mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Remove support for Audio's Global API (#5143)
* Force-disable Audio's Global API functionality * Remove owner message about global API * Two more comments * Update CODEOWNERS * Bring back the owner notification, modified to not mention global DB * Remove the global api group fully, remove the mentions of it
This commit is contained in:
parent
be04ec1c86
commit
a99240f7c3
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@ -1,5 +1,5 @@
|
|||||||
# Cogs
|
# Cogs
|
||||||
/redbot/cogs/audio/** @aikaterna @Drapersniper @PredaaA
|
/redbot/cogs/audio/** @aikaterna @PredaaA
|
||||||
/redbot/cogs/downloader/* @jack1142
|
/redbot/cogs/downloader/* @jack1142
|
||||||
/redbot/cogs/streams/* @palmtree5
|
/redbot/cogs/streams/* @palmtree5
|
||||||
/redbot/cogs/mutes/* @TrustyJAID
|
/redbot/cogs/mutes/* @TrustyJAID
|
||||||
|
|||||||
@ -174,7 +174,8 @@ class GlobalCacheWrapper:
|
|||||||
async def get_perms(self):
|
async def get_perms(self):
|
||||||
global_api_user = copy(self.cog.global_api_user)
|
global_api_user = copy(self.cog.global_api_user)
|
||||||
await self._get_api_key()
|
await self._get_api_key()
|
||||||
is_enabled = await self.config.global_db_enabled()
|
# global API is force-disabled right now
|
||||||
|
is_enabled = False
|
||||||
if (not is_enabled) or self.api_key is None:
|
if (not is_enabled) or self.api_key is None:
|
||||||
return global_api_user
|
return global_api_user
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
|
|||||||
@ -1085,15 +1085,11 @@ class AudioSetCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
+ _("Local Spotify cache: [{spotify_status}]\n")
|
+ _("Local Spotify cache: [{spotify_status}]\n")
|
||||||
+ _("Local Youtube cache: [{youtube_status}]\n")
|
+ _("Local Youtube cache: [{youtube_status}]\n")
|
||||||
+ _("Local Lavalink cache: [{lavalink_status}]\n")
|
+ _("Local Lavalink cache: [{lavalink_status}]\n")
|
||||||
+ _("Global cache status: [{global_cache}]\n")
|
|
||||||
+ _("Global timeout: [{num_seconds}]\n")
|
|
||||||
).format(
|
).format(
|
||||||
max_age=str(await self.config.cache_age()) + " " + _("days"),
|
max_age=str(await self.config.cache_age()) + " " + _("days"),
|
||||||
spotify_status=_("Enabled") if has_spotify_cache else _("Disabled"),
|
spotify_status=_("Enabled") if has_spotify_cache else _("Disabled"),
|
||||||
youtube_status=_("Enabled") if has_youtube_cache else _("Disabled"),
|
youtube_status=_("Enabled") if has_youtube_cache else _("Disabled"),
|
||||||
lavalink_status=_("Enabled") if has_lavalink_cache else _("Disabled"),
|
lavalink_status=_("Enabled") if has_lavalink_cache else _("Disabled"),
|
||||||
global_cache=_("Enabled") if global_data["global_db_enabled"] else _("Disabled"),
|
|
||||||
num_seconds=self.get_time_string(global_data["global_db_get_timeout"]),
|
|
||||||
)
|
)
|
||||||
msg += (
|
msg += (
|
||||||
"\n---"
|
"\n---"
|
||||||
@ -1422,37 +1418,6 @@ class AudioSetCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
await self.config.cache_age.set(age)
|
await self.config.cache_age.set(age)
|
||||||
await self.send_embed_msg(ctx, title=_("Setting Changed"), description=msg)
|
await self.send_embed_msg(ctx, title=_("Setting Changed"), description=msg)
|
||||||
|
|
||||||
@commands.is_owner()
|
|
||||||
@command_audioset.group(name="globalapi")
|
|
||||||
async def command_audioset_audiodb(self, ctx: commands.Context):
|
|
||||||
"""Change globalapi settings."""
|
|
||||||
|
|
||||||
@command_audioset_audiodb.command(name="toggle")
|
|
||||||
async def command_audioset_audiodb_toggle(self, ctx: commands.Context):
|
|
||||||
"""Toggle the server settings.
|
|
||||||
|
|
||||||
Default is OFF
|
|
||||||
"""
|
|
||||||
state = await self.config.global_db_enabled()
|
|
||||||
await self.config.global_db_enabled.set(not state)
|
|
||||||
if not state: # Ensure a call is made if the API is enabled to update user perms
|
|
||||||
self.global_api_user = await self.api_interface.global_cache_api.get_perms()
|
|
||||||
await ctx.send(
|
|
||||||
_("Global DB is {status}").format(status=_("enabled") if not state else _("disabled"))
|
|
||||||
)
|
|
||||||
|
|
||||||
@command_audioset_audiodb.command(name="timeout")
|
|
||||||
async def command_audioset_audiodb_timeout(
|
|
||||||
self, ctx: commands.Context, timeout: Union[float, int]
|
|
||||||
):
|
|
||||||
"""Set GET request timeout.
|
|
||||||
|
|
||||||
Example: 0.1 = 100ms 1 = 1 second
|
|
||||||
"""
|
|
||||||
|
|
||||||
await self.config.global_db_get_timeout.set(timeout)
|
|
||||||
await ctx.send(_("Request timeout set to {time} second(s)").format(time=timeout))
|
|
||||||
|
|
||||||
@command_audioset.command(name="persistqueue")
|
@command_audioset.command(name="persistqueue")
|
||||||
@commands.admin()
|
@commands.admin()
|
||||||
async def command_audioset_persist_queue(self, ctx: commands.Context):
|
async def command_audioset_persist_queue(self, ctx: commands.Context):
|
||||||
|
|||||||
@ -39,7 +39,6 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
await self.bot.wait_until_red_ready()
|
await self.bot.wait_until_red_ready()
|
||||||
# Unlike most cases, we want the cache to exit before migration.
|
# Unlike most cases, we want the cache to exit before migration.
|
||||||
try:
|
try:
|
||||||
await self.maybe_message_all_owners()
|
|
||||||
self.db_conn = APSWConnectionWrapper(
|
self.db_conn = APSWConnectionWrapper(
|
||||||
str(cog_data_path(self.bot.get_cog("Audio")) / "Audio.db")
|
str(cog_data_path(self.bot.get_cog("Audio")) / "Audio.db")
|
||||||
)
|
)
|
||||||
@ -246,21 +245,3 @@ class StartUpTasks(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
return
|
return
|
||||||
del metadata
|
del metadata
|
||||||
del all_guilds
|
del all_guilds
|
||||||
|
|
||||||
async def maybe_message_all_owners(self):
|
|
||||||
current_notification = await self.config.owner_notification()
|
|
||||||
if current_notification == _OWNER_NOTIFICATION:
|
|
||||||
return
|
|
||||||
if current_notification < 1 <= _OWNER_NOTIFICATION:
|
|
||||||
msg = _(
|
|
||||||
"""Hello, this message brings you an important update regarding the core Audio cog:
|
|
||||||
|
|
||||||
Starting from Audio v2.3.0+ you can take advantage of the **Global Audio API**, a new service offered by the Cog-Creators organization that allows your bot to greatly reduce the amount of requests done to YouTube / Spotify. This reduces the likelihood of YouTube rate-limiting your bot for making requests too often.
|
|
||||||
See `[p]help audioset globalapi` for more information.
|
|
||||||
Access to this service is disabled by default and **requires you to explicitly opt-in** to start using it.
|
|
||||||
|
|
||||||
An access token is **required** to use this API. To obtain this token you may join <https://discord.gg/red> and run `?audioapi register` in the #testing channel.
|
|
||||||
Note: by using this service you accept that your bot's IP address will be disclosed to the Cog-Creators organization and used only for the purpose of providing the Global API service."""
|
|
||||||
)
|
|
||||||
await send_to_owners_with_prefix_replaced(self.bot, msg)
|
|
||||||
await self.config.owner_notification.set(1)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user