Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix
Browse files
app.py
CHANGED
@@ -45,7 +45,6 @@ async def on_message(message):
|
|
45 |
global number_of_messages
|
46 |
if message.author != bot.user:
|
47 |
message_cache[message.id] = message
|
48 |
-
lunarflu = bot.get_user(811235357663297546) # might not need
|
49 |
|
50 |
|
51 |
"""Backup"""
|
@@ -63,22 +62,10 @@ async def on_message(message):
|
|
63 |
if message.embeds:
|
64 |
for embed in message.embeds:
|
65 |
backup_message += f"\nEmbed Title: {embed.title}\nEmbed Description: {embed.description}"
|
66 |
-
dm_message = await
|
|
|
67 |
|
68 |
"""Antispam"""
|
69 |
-
#Detecting certain unwanted strings
|
70 |
-
try:
|
71 |
-
forbidden_patterns = [r"@everyone",
|
72 |
-
r"@here",
|
73 |
-
r"(https?:\/\/|http?:\/\/)?(www.)?(discord.(gg|io|me|li)|discordapp.com\/invite|discord.com\/invite)\/[^\s\/]+?(?=\b)"]
|
74 |
-
if any(re.search(pattern, message.content, re.IGNORECASE) for pattern in forbidden_patterns):
|
75 |
-
ignored_role_ids = [897381378172264449, 897376942817419265] #admins, supermods, mods
|
76 |
-
if any(role.id in ignored_role_ids for role in message.author.roles):
|
77 |
-
if message.author != lunarflu:
|
78 |
-
return
|
79 |
-
dm_unwanted = await lunarflu.send(f" {lunarflu.mention} [experimental] SUSPICIOUS MESSAGE: {message_link} | {message.author}: {message.content}")
|
80 |
-
except Exception as e:
|
81 |
-
print(f"Antispam->Detecting certain unwanted strings Error: {e}")
|
82 |
|
83 |
#Posting too fast
|
84 |
"""
|
@@ -122,18 +109,14 @@ async def on_message(message):
|
|
122 |
channel = message.channel
|
123 |
if spam_count == false_positive_threshold:
|
124 |
if channel.id != 996580741121065091: # admin channel excluded due to how automod messages are categorized by the discord bot
|
125 |
-
await channel.send(f"{message.author.mention}, you may be posting too quickly! Please slow down a bit
|
126 |
|
127 |
var1 = message.created_at
|
128 |
var2 = user_cooldowns[message.author.id]['timestamp']
|
129 |
print(f"seconds since last message by {message.author}: {(var1 - var2).total_seconds()}")
|
130 |
print(f"spam_count: {spam_count}")
|
131 |
|
132 |
-
|
133 |
-
if test_server == 'True':
|
134 |
-
alert = "<@&1106995261487710411>" # test @alerts role
|
135 |
-
if test_server == 'False':
|
136 |
-
alert = "<@&1108342563628404747>" # normal @alerts role
|
137 |
|
138 |
await bot.log_channel.send(
|
139 |
f"[EXPERIMENTAL ALERT] {message.author} may be posting too quickly! \n"
|
@@ -142,25 +125,6 @@ async def on_message(message):
|
|
142 |
f"[Jump to message!](https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id})\n"
|
143 |
f"{alert}"
|
144 |
)
|
145 |
-
await cakiki.send(
|
146 |
-
f"[EXPERIMENTAL ALERT] {message.author} may be posting too quickly! \n"
|
147 |
-
f"Spam count: {spam_count}\n"
|
148 |
-
f"Message content: {message.content}\n"
|
149 |
-
f"[Jump to message!](https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id})\n"
|
150 |
-
)
|
151 |
-
# automatically take action based on spam_count - this doesn't work at the moment
|
152 |
-
"""
|
153 |
-
if spam_count >= timeout_threshold:
|
154 |
-
try:
|
155 |
-
member = message.author
|
156 |
-
await member.send(
|
157 |
-
"You have been auto-banned for spamming. \n If this was an error, message <@811235357663297546> ."
|
158 |
-
)
|
159 |
-
await member.ban()
|
160 |
-
except Exception as e:
|
161 |
-
print(f"Error: {e}")
|
162 |
-
|
163 |
-
"""
|
164 |
|
165 |
|
166 |
user_cooldowns[message.author.id]['timestamp'] = message.created_at
|
@@ -309,7 +273,7 @@ async def on_member_ban(guild, banned_user):
|
|
309 |
else:
|
310 |
print(f'{entry2.user} banned {entry2.target} (no reason specified)')
|
311 |
|
312 |
-
content = "<@&
|
313 |
embed = Embed(color=Color.red())
|
314 |
embed.set_author(name=f"{entry2.target} ID: {entry2.target.id}", icon_url=entry2.target.avatar.url if entry2.target.avatar else bot.user.avatar.url)
|
315 |
embed.title = "User Banned"
|
@@ -344,7 +308,7 @@ async def on_member_unban(guild, unbanned_user):
|
|
344 |
moderator = entry.user
|
345 |
|
346 |
created_and_age = f"{unbanned_user.created_at}"
|
347 |
-
content = "<@&
|
348 |
embed = Embed(color=Color.red())
|
349 |
embed.set_author(name=f"{unbanned_user} ID: {unbanned_user.id}", icon_url=unbanned_user.avatar.url if unbanned_user.avatar else bot.user.avatar.url)
|
350 |
embed.title = "User Unbanned"
|
@@ -367,11 +331,8 @@ async def on_member_join(member):
|
|
367 |
try:
|
368 |
await asyncio.sleep(5)
|
369 |
# initialize lvl1 on join
|
370 |
-
guild = bot.get_guild(
|
371 |
-
|
372 |
-
member2 = guild.get_member(member.id)
|
373 |
-
await member2.add_roles(lvl1)
|
374 |
-
|
375 |
embed = Embed(color=Color.blue())
|
376 |
avatar_url = member.avatar.url if member.avatar else bot.user.avatar.url
|
377 |
embed.set_author(name=f"{member} ID: {member.id}", icon_url=avatar_url)
|
@@ -473,7 +434,7 @@ async def on_guild_role_update(before, after):
|
|
473 |
|
474 |
if before.permissions.administrator != after.permissions.administrator:
|
475 |
# changes involving the administrator permission / sensitive permissions (can help to prevent mistakes)
|
476 |
-
content = "<@&
|
477 |
embed = Embed(description=f'Role {after.mention} had its administrator permission {"enabled" if after.permissions.administrator else "disabled"}', color=Color.red())
|
478 |
await bot.log_channel.send(content=content, embed=embed)
|
479 |
except Exception as e:
|
@@ -560,10 +521,10 @@ async def on_ready():
|
|
560 |
await asyncio.sleep(5)
|
561 |
print('Logged on as', bot.user)
|
562 |
await asyncio.sleep(5)
|
563 |
-
bot.log_channel = bot.get_channel(
|
564 |
await asyncio.sleep(5)
|
565 |
print(bot.log_channel)
|
566 |
-
guild = bot.get_guild(
|
567 |
|
568 |
|
569 |
for channel in guild.text_channels: # helps with more accurate logging across restarts
|
|
|
45 |
global number_of_messages
|
46 |
if message.author != bot.user:
|
47 |
message_cache[message.id] = message
|
|
|
48 |
|
49 |
|
50 |
"""Backup"""
|
|
|
62 |
if message.embeds:
|
63 |
for embed in message.embeds:
|
64 |
backup_message += f"\nEmbed Title: {embed.title}\nEmbed Description: {embed.description}"
|
65 |
+
dm_message = await bot.log_channel.send(backup_message)
|
66 |
+
|
67 |
|
68 |
"""Antispam"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
#Posting too fast
|
71 |
"""
|
|
|
109 |
channel = message.channel
|
110 |
if spam_count == false_positive_threshold:
|
111 |
if channel.id != 996580741121065091: # admin channel excluded due to how automod messages are categorized by the discord bot
|
112 |
+
await channel.send(f"{message.author.mention}, you may be posting too quickly! Please slow down a bit ")
|
113 |
|
114 |
var1 = message.created_at
|
115 |
var2 = user_cooldowns[message.author.id]['timestamp']
|
116 |
print(f"seconds since last message by {message.author}: {(var1 - var2).total_seconds()}")
|
117 |
print(f"spam_count: {spam_count}")
|
118 |
|
119 |
+
alert = "<@&1375548644379332658>" # normal @alerts role
|
|
|
|
|
|
|
|
|
120 |
|
121 |
await bot.log_channel.send(
|
122 |
f"[EXPERIMENTAL ALERT] {message.author} may be posting too quickly! \n"
|
|
|
125 |
f"[Jump to message!](https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id})\n"
|
126 |
f"{alert}"
|
127 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
|
130 |
user_cooldowns[message.author.id]['timestamp'] = message.created_at
|
|
|
273 |
else:
|
274 |
print(f'{entry2.user} banned {entry2.target} (no reason specified)')
|
275 |
|
276 |
+
content = "<@&1375548644379332658>" # @alerts role
|
277 |
embed = Embed(color=Color.red())
|
278 |
embed.set_author(name=f"{entry2.target} ID: {entry2.target.id}", icon_url=entry2.target.avatar.url if entry2.target.avatar else bot.user.avatar.url)
|
279 |
embed.title = "User Banned"
|
|
|
308 |
moderator = entry.user
|
309 |
|
310 |
created_and_age = f"{unbanned_user.created_at}"
|
311 |
+
content = "<@&1375548644379332658>" # @alerts role
|
312 |
embed = Embed(color=Color.red())
|
313 |
embed.set_author(name=f"{unbanned_user} ID: {unbanned_user.id}", icon_url=unbanned_user.avatar.url if unbanned_user.avatar else bot.user.avatar.url)
|
314 |
embed.title = "User Unbanned"
|
|
|
331 |
try:
|
332 |
await asyncio.sleep(5)
|
333 |
# initialize lvl1 on join
|
334 |
+
guild = bot.get_guild(1346208250995015754)
|
335 |
+
|
|
|
|
|
|
|
336 |
embed = Embed(color=Color.blue())
|
337 |
avatar_url = member.avatar.url if member.avatar else bot.user.avatar.url
|
338 |
embed.set_author(name=f"{member} ID: {member.id}", icon_url=avatar_url)
|
|
|
434 |
|
435 |
if before.permissions.administrator != after.permissions.administrator:
|
436 |
# changes involving the administrator permission / sensitive permissions (can help to prevent mistakes)
|
437 |
+
content = "<@&1375548644379332658>" # @alerts role
|
438 |
embed = Embed(description=f'Role {after.mention} had its administrator permission {"enabled" if after.permissions.administrator else "disabled"}', color=Color.red())
|
439 |
await bot.log_channel.send(content=content, embed=embed)
|
440 |
except Exception as e:
|
|
|
521 |
await asyncio.sleep(5)
|
522 |
print('Logged on as', bot.user)
|
523 |
await asyncio.sleep(5)
|
524 |
+
bot.log_channel = bot.get_channel(1375549560515989677) # custom logs
|
525 |
await asyncio.sleep(5)
|
526 |
print(bot.log_channel)
|
527 |
+
guild = bot.get_guild(1346208250995015754)
|
528 |
|
529 |
|
530 |
for channel in guild.text_channels: # helps with more accurate logging across restarts
|