repost message when a tiktok link is detected for embed compatibility

This commit is contained in:
Mylloon 2021-09-06 11:44:19 +02:00
parent 5180500d7e
commit c5e7271296

View file

@ -4,6 +4,7 @@ from discord.ext import commands
from random import choice
from asyncpraw import Reddit
from discord_slash import cog_ext
from re import findall
from utils.core import randomImage, isSlash, mySendHidden, load, addReaction
def setup(client):
@ -198,3 +199,17 @@ class Internet(commands.Cog):
return await self._news(ctx, True)
else:
return await self._news(ctx, source, True)
@commands.Cog.listener()
async def on_message(self, message):
"""Triggered a message is received for tiktok"""
if message.author.bot:
return
urls = findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', message.content)
for url in urls:
url_embed = url.replace("tiktok.com", "dstn.to")
if message.content == url.replace(' ',''):
await message.channel.send(url_embed)
await message.delete()
else:
await message.reply(url_embed, mention_author = False)