|
1 | 1 | import asyncio |
2 | 2 | import json |
3 | 3 | import re |
4 | | -from datetime import datetime |
| 4 | +from datetime import datetime, timedelta |
5 | 5 |
|
6 | 6 | import discord |
7 | 7 | from discord.ext import commands |
@@ -69,7 +69,7 @@ async def on_message_delete(self, message): |
69 | 69 |
|
70 | 70 | attach_txt = "" |
71 | 71 | for i in range(len(message.attachments)): |
72 | | - attach_txt += f"File {i + 1}\n" f"Name: {message.attachments[i].filename}\n" |
| 72 | + attach_txt += f"File {i + 1}\nName: {message.attachments[i].filename}\n" |
73 | 73 | if message.attachments[i].height is not None: |
74 | 74 | # Then the file is an image |
75 | 75 | embed.set_image(url=message.attachments[i].proxy_url) |
@@ -105,12 +105,23 @@ async def on_message_delete(self, message): |
105 | 105 | print("Can't send deleted message") |
106 | 106 |
|
107 | 107 | @commands.Cog.listener() |
108 | | - async def on_message(self, message): |
109 | | - if ( |
110 | | - message.author.id == 755781649643470868 |
111 | | - or message.author.id == 776713845238136843 |
112 | | - ): |
| 108 | + async def on_message(self, message: discord.Message): |
| 109 | + if message.author.id == (self.bot.user.id if self.bot.user else 0): |
113 | 110 | return |
| 111 | + |
| 112 | + # remove annoying si link messages if replying to owner |
| 113 | + if message.author.bot and (ref := message.reference): |
| 114 | + if ref.message_id and ref.type == discord.MessageReferenceType.reply: |
| 115 | + ref_message = await message.channel.fetch_message(ref.message_id) |
| 116 | + if ( |
| 117 | + ref_message.author.id == self.bot.owner_id |
| 118 | + and "si=" in ref_message.content |
| 119 | + and ref_message.created_at |
| 120 | + < message.created_at + timedelta(seconds=5) |
| 121 | + ): |
| 122 | + await message.delete() |
| 123 | + return |
| 124 | + |
114 | 125 | if message.channel.id in [ |
115 | 126 | 747776646551175217, |
116 | 127 | 768600365602963496, |
|
0 commit comments