mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 21:44:21 +00:00
Update /cv escape method
This commit is contained in:
parent
0ae6992f2f
commit
3748980d7b
1 changed files with 13 additions and 10 deletions
|
@ -220,6 +220,10 @@ class SecretVideo(Video):
|
||||||
return discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(f"./opusfiles/{self.file}", **ffmpeg_settings))
|
return discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(f"./opusfiles/{self.file}", **ffmpeg_settings))
|
||||||
|
|
||||||
|
|
||||||
|
def escape(message: str):
|
||||||
|
return message.replace("<", "<").replace(">", ">")
|
||||||
|
|
||||||
|
|
||||||
def command(func):
|
def command(func):
|
||||||
"""Decorator. Runs the function as a Discord command."""
|
"""Decorator. Runs the function as a Discord command."""
|
||||||
|
|
||||||
|
@ -420,7 +424,7 @@ class RoyalDiscordBot(discord.Client):
|
||||||
if channel == 0:
|
if channel == 0:
|
||||||
message += "<b>Non in chat vocale:</b>\n"
|
message += "<b>Non in chat vocale:</b>\n"
|
||||||
else:
|
else:
|
||||||
message += f"<b>In #{channels[channel].name}:</b>\n"
|
message += f"<b>In #{escape(channels[channel].name)}:</b>\n"
|
||||||
for member in members_in_channels[channel]:
|
for member in members_in_channels[channel]:
|
||||||
# Ignore not-connected non-notable members
|
# Ignore not-connected non-notable members
|
||||||
if channel == 0 and len(member.roles) < 2:
|
if channel == 0 and len(member.roles) < 2:
|
||||||
|
@ -450,32 +454,31 @@ class RoyalDiscordBot(discord.Client):
|
||||||
message += f"🔊 "
|
message += f"🔊 "
|
||||||
# Nickname
|
# Nickname
|
||||||
if member.nick is not None:
|
if member.nick is not None:
|
||||||
message += member.nick
|
message += escape(member.nick)
|
||||||
else:
|
else:
|
||||||
message += member.name
|
message += escape(member.name)
|
||||||
# Game or stream
|
# Game or stream
|
||||||
if member.activity is not None:
|
if member.activity is not None:
|
||||||
if member.activity.type == discord.ActivityType.playing:
|
if member.activity.type == discord.ActivityType.playing:
|
||||||
message += f" | 🎮 {member.activity.name}"
|
message += f" | 🎮 {escape(member.activity.name)}"
|
||||||
# Rich presence
|
# Rich presence
|
||||||
try:
|
try:
|
||||||
if member.activity.state is not None:
|
if member.activity.state is not None:
|
||||||
message += f" ({member.activity.state})"
|
message += f" ({escape(member.activity.state)})"
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
try:
|
try:
|
||||||
if member.activity.details is not None:
|
if member.activity.details is not None:
|
||||||
message += f" ({member.activity.details})"
|
message += f" ({escape(member.activity.details)})"
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
elif member.activity.type == discord.ActivityType.streaming:
|
elif member.activity.type == discord.ActivityType.streaming:
|
||||||
message += f" | 📡 [{member.activity.name}]({member.activity.url})"
|
message += f" | 📡 [{escape(member.activity.name)}]({escape(member.activity.url)})"
|
||||||
elif member.activity.type == discord.ActivityType.listening:
|
elif member.activity.type == discord.ActivityType.listening:
|
||||||
message += f" | 🎧 {member.activity.name}"
|
message += f" | 🎧 {escape(member.activity.name)}"
|
||||||
elif member.activity.type == discord.ActivityType.watching:
|
elif member.activity.type == discord.ActivityType.watching:
|
||||||
message += f" | 📺 {member.activity.name}"
|
message += f" | 📺 {escape(member.activity.name)}"
|
||||||
message += "\n"
|
message += "\n"
|
||||||
message += "\n"
|
message += "\n"
|
||||||
message = message.replace("<", "<").replace(">", ">")
|
|
||||||
connection.send(message)
|
connection.send(message)
|
||||||
logger.debug(f"Answered successfully cvlist request.")
|
logger.debug(f"Answered successfully cvlist request.")
|
||||||
elif msg.startswith("!"):
|
elif msg.startswith("!"):
|
||||||
|
|
Loading…
Reference in a new issue