repost message when a tiktok link is detected for embed compatibility
This commit is contained in:
parent
5180500d7e
commit
c5e7271296
1 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,7 @@ from discord.ext import commands
|
||||||
from random import choice
|
from random import choice
|
||||||
from asyncpraw import Reddit
|
from asyncpraw import Reddit
|
||||||
from discord_slash import cog_ext
|
from discord_slash import cog_ext
|
||||||
|
from re import findall
|
||||||
from utils.core import randomImage, isSlash, mySendHidden, load, addReaction
|
from utils.core import randomImage, isSlash, mySendHidden, load, addReaction
|
||||||
|
|
||||||
def setup(client):
|
def setup(client):
|
||||||
|
@ -198,3 +199,17 @@ class Internet(commands.Cog):
|
||||||
return await self._news(ctx, True)
|
return await self._news(ctx, True)
|
||||||
else:
|
else:
|
||||||
return await self._news(ctx, source, True)
|
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)
|
||||||
|
|
Reference in a new issue