-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
48 lines (38 loc) · 1.66 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import discord, re
intents = discord.Intents.default()
intents.message_content = True
TOKEN = "" # Replace this with your Discord token
REGEX_LINK = r"(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])"
class Ahso(discord.Bot):
async def on_ready(self):
print(f'Logged on as {self.user}')
bot = Ahso(intents=intents)
@bot.slash_command(description="Be sorry")
async def ahsosorry(ctx):
await ctx.respond(content = "ah! so sorry!", file = discord.File(fp = "media/ahsosorry.webp"))
@bot.slash_command(description="Be jolly")
async def ahsojolly(ctx):
await ctx.respond(content = "ah! so jolly!", file = discord.File(fp = "media/ahsojolly.jpg"))
@bot.slash_command(description="Be happy")
async def ahsohappy(ctx):
await ctx.respond(content = "ah! so happy!", file = discord.File(fp = "media/ahsohappy.jpg"))
@bot.event
async def on_message(message):
msg = message.content
dic = {
"twitter.com":"fxtwitter.com",
"www.twitter.com":"fxtwitter.com",
"x.com":"fxtwitter.com",
"www.x.com":"fxtwitter.com",
"instagram.com":"ddinstagram.com",
"www.instagram.com":"ddinstagram.com"
}
matches = re.findall(REGEX_LINK, msg)
if len(matches) == 0:
return
for el in matches:
if el[1] in dic and (("/p/" in el[2]) or ("/reel/" in el[2]) or ("/status/" in el[2])):
await message.channel.send(content = f"{message.author.mention} sent the following link : {el[0]}://{dic[el[1]]}{el[2]}")
if msg == el[0] + "://" + el[1] + el[2] :
await message.delete()
bot.run(TOKEN)