Fix twitter fix
All checks were successful
Build and Publish / build_and_publish (push) Successful in 53s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 53s
This commit is contained in:
parent
8264680e21
commit
8a72ea7ddd
1 changed files with 16 additions and 13 deletions
|
@ -500,6 +500,8 @@ class NetworkCog(commands.Cog):
|
|||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message: discord.Message):
|
||||
if message.author.bot:
|
||||
return
|
||||
content = message.content.split()
|
||||
new_links = []
|
||||
for section in content:
|
||||
|
@ -510,19 +512,20 @@ class NetworkCog(commands.Cog):
|
|||
if parsed.netloc in ("x.com", "twitter.com"):
|
||||
parsed = parsed._replace(netloc="fixupx.com")
|
||||
new_links.append(parsed.geturl())
|
||||
if len(content) == 1: # just link
|
||||
await message.delete(delay=0.1, reason="Fixed twitter link")
|
||||
await message.channel.send(
|
||||
f"**{message.author.mention}**:\n" + " | ".join(new_links),
|
||||
allowed_mentions=discord.AllowedMentions.none(),
|
||||
)
|
||||
else:
|
||||
await message.edit(suppress=True)
|
||||
await message.channel.send(
|
||||
" | ".join(new_links),
|
||||
allowed_mentions=discord.AllowedMentions.none(),
|
||||
reference=message
|
||||
)
|
||||
if new_links:
|
||||
if len(content) == 1: # just link
|
||||
await message.delete(delay=0.1, reason="Fixed twitter link")
|
||||
await message.channel.send(
|
||||
f"**{message.author.mention}**:\n" + " | ".join(new_links),
|
||||
allowed_mentions=discord.AllowedMentions.none(),
|
||||
)
|
||||
else:
|
||||
await message.edit(suppress=True)
|
||||
await message.channel.send(
|
||||
" | ".join(new_links),
|
||||
allowed_mentions=discord.AllowedMentions.none(),
|
||||
reference=message
|
||||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
Loading…
Reference in a new issue