mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Streams] Only send message about missing client secret once (#3901)
* Send Notify owner messages only when a key has been invalidated since last notify_owner * grammar * welp im dumb * Black and lower config call frequency * Update redbot/cogs/streams/streams.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * dont use a generic name now to avoid a config migration later * be even more explicit with var name Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
dd4095b15b
commit
79d042ad29
@ -44,7 +44,12 @@ class Streams(commands.Cog):
|
|||||||
currently live.
|
currently live.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global_defaults = {"refresh_timer": 300, "tokens": {}, "streams": []}
|
global_defaults = {
|
||||||
|
"refresh_timer": 300,
|
||||||
|
"tokens": {},
|
||||||
|
"streams": [],
|
||||||
|
"notified_owner_missing_twitch_secret": False,
|
||||||
|
}
|
||||||
|
|
||||||
guild_defaults = {
|
guild_defaults = {
|
||||||
"autodelete": False,
|
"autodelete": False,
|
||||||
@ -114,11 +119,16 @@ class Streams(commands.Cog):
|
|||||||
async def get_twitch_bearer_token(self) -> None:
|
async def get_twitch_bearer_token(self) -> None:
|
||||||
tokens = await self.bot.get_shared_api_tokens("twitch")
|
tokens = await self.bot.get_shared_api_tokens("twitch")
|
||||||
if tokens.get("client_id"):
|
if tokens.get("client_id"):
|
||||||
|
notified_owner_missing_twitch_secret = (
|
||||||
|
await self.config.notified_owner_missing_twitch_secret()
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
tokens["client_secret"]
|
tokens["client_secret"]
|
||||||
|
if notified_owner_missing_twitch_secret is True:
|
||||||
|
await self.config.notified_owner_missing_twitch_secret.set(False)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
message = _(
|
message = _(
|
||||||
"You need a client secret key to use correctly Twitch API on this cog.\n"
|
"You need a client secret key if you want to use the Twitch API on this cog.\n"
|
||||||
"Follow these steps:\n"
|
"Follow these steps:\n"
|
||||||
"1. Go to this page: https://dev.twitch.tv/console/apps.\n"
|
"1. Go to this page: https://dev.twitch.tv/console/apps.\n"
|
||||||
'2. Click "Manage" on your application.\n'
|
'2. Click "Manage" on your application.\n'
|
||||||
@ -126,10 +136,13 @@ class Streams(commands.Cog):
|
|||||||
"5. Copy your client ID and your client secret into:\n"
|
"5. Copy your client ID and your client secret into:\n"
|
||||||
"`[p]set api twitch client_id <your_client_id_here> "
|
"`[p]set api twitch client_id <your_client_id_here> "
|
||||||
"client_secret <your_client_secret_here>`\n\n"
|
"client_secret <your_client_secret_here>`\n\n"
|
||||||
"Note: These tokens are sensitive and should only be used in a private channel "
|
"Note: These tokens are sensitive and should "
|
||||||
|
"only be used in a private channel "
|
||||||
"or in DM with the bot."
|
"or in DM with the bot."
|
||||||
)
|
)
|
||||||
await send_to_owners_with_prefix_replaced(self.bot, message)
|
if notified_owner_missing_twitch_secret is False:
|
||||||
|
await send_to_owners_with_prefix_replaced(self.bot, message)
|
||||||
|
await self.config.notified_owner_missing_twitch_secret.set(True)
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.post(
|
async with session.post(
|
||||||
"https://id.twitch.tv/oauth2/token",
|
"https://id.twitch.tv/oauth2/token",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user