mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Fix the bug with Twitch display name being set as Twitch login (#5066)
This commit is contained in:
parent
982feda858
commit
f8ecc32dbc
@ -200,7 +200,10 @@ Use ``{mention}`` in the message to insert the selected mentions.
|
||||
|
||||
Use ``{stream}`` in the message to insert the channel or user name.
|
||||
|
||||
For example: ``[p]streamset message mention {mention}, {stream} is live!``
|
||||
Use ``{stream.display_name}`` in the message to insert the channel's display name
|
||||
(on Twitch, this may be different from ``{stream}``).
|
||||
|
||||
For example: ``[p]streamset message mention {mention}, {stream.display_name} is live!``
|
||||
|
||||
**Arguments**
|
||||
|
||||
@ -224,7 +227,10 @@ Sets a stream alert message for when mentions are disabled.
|
||||
|
||||
Use ``{stream}`` in the message to insert the channel or user name.
|
||||
|
||||
For example: ``[p]streamset message nomention {stream} is live!``
|
||||
Use ``{stream.display_name}`` in the message to insert the channel's display name
|
||||
(on Twitch, this may be different from ``{stream}``).
|
||||
|
||||
For example: ``[p]streamset message nomention {stream.display_name} is live!``
|
||||
|
||||
**Arguments**
|
||||
|
||||
|
||||
@ -528,9 +528,10 @@ class Streams(commands.Cog):
|
||||
"""Set stream alert message when mentions are enabled.
|
||||
|
||||
Use `{mention}` in the message to insert the selected mentions.
|
||||
Use `{stream}` in the message to insert the channel or user name.
|
||||
Use `{stream}` in the message to insert the channel or username.
|
||||
Use `{stream.display_name}` in the message to insert the channel's display name (on Twitch, this may be different from `{stream}`).
|
||||
|
||||
For example: `[p]streamset message mention {mention}, {stream} is live!`
|
||||
For example: `[p]streamset message mention {mention}, {stream.display_name} is live!`
|
||||
"""
|
||||
guild = ctx.guild
|
||||
await self.config.guild(guild).live_message_mention.set(message)
|
||||
@ -541,9 +542,10 @@ class Streams(commands.Cog):
|
||||
async def without_mention(self, ctx: commands.Context, *, message: str):
|
||||
"""Set stream alert message when mentions are disabled.
|
||||
|
||||
Use `{stream}` in the message to insert the channel or user name.
|
||||
Use `{stream}` in the message to insert the channel or username.
|
||||
Use `{stream.display_name}` in the message to insert the channel's display name (on Twitch, this may be different from `{stream}`).
|
||||
|
||||
For example: `[p]streamset message nomention {stream} is live!`
|
||||
For example: `[p]streamset message nomention {stream.display_name} is live!`
|
||||
"""
|
||||
guild = ctx.guild
|
||||
await self.config.guild(guild).live_message_nomention.set(message)
|
||||
@ -808,13 +810,18 @@ class Streams(commands.Cog):
|
||||
content = content.replace(
|
||||
"{stream.name}", str(stream.name)
|
||||
) # Backwards compatibility
|
||||
content = content.replace(
|
||||
"{stream.display_name}", str(stream.display_name)
|
||||
)
|
||||
content = content.replace("{stream}", str(stream.name))
|
||||
content = content.replace("{mention}", mention_str)
|
||||
else:
|
||||
content = _("{mention}, {stream} is live!").format(
|
||||
content = _("{mention}, {display_name} is live!").format(
|
||||
mention=mention_str,
|
||||
stream=escape(
|
||||
str(stream.name), mass_mentions=True, formatting=True
|
||||
display_name=escape(
|
||||
str(stream.display_name),
|
||||
mass_mentions=True,
|
||||
formatting=True,
|
||||
),
|
||||
)
|
||||
else:
|
||||
@ -826,11 +833,16 @@ class Streams(commands.Cog):
|
||||
content = content.replace(
|
||||
"{stream.name}", str(stream.name)
|
||||
) # Backwards compatibility
|
||||
content = content.replace(
|
||||
"{stream.display_name}", str(stream.display_name)
|
||||
)
|
||||
content = content.replace("{stream}", str(stream.name))
|
||||
else:
|
||||
content = _("{stream} is live!").format(
|
||||
stream=escape(
|
||||
str(stream.name), mass_mentions=True, formatting=True
|
||||
content = _("{display_name} is live!").format(
|
||||
display_name=escape(
|
||||
str(stream.display_name),
|
||||
mass_mentions=True,
|
||||
formatting=True,
|
||||
)
|
||||
)
|
||||
await self._send_stream_alert(stream, channel, embed, content)
|
||||
|
||||
@ -65,6 +65,10 @@ class Stream:
|
||||
self.messages = kwargs.pop("messages", [])
|
||||
self.type = self.__class__.__name__
|
||||
|
||||
@property
|
||||
def display_name(self) -> Optional[str]:
|
||||
return self.name
|
||||
|
||||
async def is_online(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -299,12 +303,21 @@ class TwitchStream(Stream):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.id = kwargs.pop("id", None)
|
||||
self._display_name = None
|
||||
self._client_id = kwargs.pop("token", None)
|
||||
self._bearer = kwargs.pop("bearer", None)
|
||||
self._rate_limit_resets: set = set()
|
||||
self._rate_limit_remaining: int = 0
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@property
|
||||
def display_name(self) -> Optional[str]:
|
||||
return self._display_name or self.name
|
||||
|
||||
@display_name.setter
|
||||
def display_name(self, value: str) -> None:
|
||||
self._display_name = value
|
||||
|
||||
async def wait_for_rate_limit_reset(self) -> None:
|
||||
"""Check rate limits in response header and ensure we're following them.
|
||||
|
||||
@ -378,7 +391,7 @@ class TwitchStream(Stream):
|
||||
final_data["view_count"] = user_profile_data["view_count"]
|
||||
|
||||
stream_data = stream_data["data"][0]
|
||||
final_data["user_name"] = self.name = stream_data["user_name"]
|
||||
final_data["user_name"] = self.display_name = stream_data["user_name"]
|
||||
final_data["game_name"] = stream_data["game_name"]
|
||||
final_data["thumbnail_url"] = stream_data["thumbnail_url"]
|
||||
final_data["title"] = stream_data["title"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user