Implement #22
This commit is contained in:
parent
f7b8dee6cd
commit
d246e2f6ec
2 changed files with 27 additions and 1 deletions
26
cogs/logs.py
26
cogs/logs.py
|
@ -1,5 +1,6 @@
|
||||||
import discord
|
import discord
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
import config
|
import config
|
||||||
from helpers.restrictions import get_user_restrictions
|
from helpers.restrictions import get_user_restrictions
|
||||||
|
|
||||||
|
@ -11,6 +12,8 @@ class Logs:
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.invite_re = re.compile(r"((discord\.gg|discordapp\.com/"
|
||||||
|
r"+invite)/+[a-zA-Z0-9-]+)")
|
||||||
|
|
||||||
async def on_member_join(self, member):
|
async def on_member_join(self, member):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
|
@ -68,6 +71,27 @@ class Logs:
|
||||||
except KeyError: # if the user is not in the file
|
except KeyError: # if the user is not in the file
|
||||||
await log_channel.send(msg)
|
await log_channel.send(msg)
|
||||||
|
|
||||||
|
async def do_spy(self, message):
|
||||||
|
alert = False
|
||||||
|
msg = f"Suspicious message by {message.author.mention} "\
|
||||||
|
f"({message.author.id}):"
|
||||||
|
|
||||||
|
invites = self.invite_re.search(message.lower())
|
||||||
|
for invite in invites:
|
||||||
|
msg += f"\n- Has invite: https://{invite[0]}"
|
||||||
|
alert = True
|
||||||
|
|
||||||
|
if alert:
|
||||||
|
spy_channel = self.bot.get_channel(548304839294189579)
|
||||||
|
await spy_channel.send(msg)
|
||||||
|
|
||||||
|
async def on_message(self, message):
|
||||||
|
await self.bot.wait_until_ready()
|
||||||
|
if message.channel.id not in config.spy_channels:
|
||||||
|
return
|
||||||
|
|
||||||
|
await self.do_spy(message)
|
||||||
|
|
||||||
async def on_message_edit(self, before, after):
|
async def on_message_edit(self, before, after):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
if after.channel.id not in config.spy_channels or after.author.bot:
|
if after.channel.id not in config.spy_channels or after.author.bot:
|
||||||
|
@ -78,6 +102,8 @@ class Logs:
|
||||||
if before.clean_content == after.clean_content:
|
if before.clean_content == after.clean_content:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
await self.do_spy(after)
|
||||||
|
|
||||||
log_channel = self.bot.get_channel(config.log_channel)
|
log_channel = self.bot.get_channel(config.log_channel)
|
||||||
msg = "📝 **Message edit**: \n"\
|
msg = "📝 **Message edit**: \n"\
|
||||||
f"from {self.bot.escape_message(after.author.name)} "\
|
f"from {self.bot.escape_message(after.author.name)} "\
|
||||||
|
|
|
@ -707,7 +707,7 @@ switch_known_errcodes = {
|
||||||
|
|
||||||
# By Ave
|
# By Ave
|
||||||
|
|
||||||
0x0: "Thrown when you downgrade between major/key versions (7.0.x -> 6.2.0, 6.2.0 -> 6.1.0 etc) without initialization ( deleting system save files).\n\nTo recover from this issue: Delete system all save files except 80...120. Keep in mind that this will effectively be a factory reset.",
|
0x0: "Thrown when you downgrade between major/key versions (7.0.x -> 6.2.0, 6.2.0 -> 6.1.0 etc) without initialization (deleting system save files).\n\nTo recover from this issue: Delete system all save files except 80...120. Keep in mind that this will effectively be a factory reset.",
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_known_errcode_ranges = {
|
switch_known_errcode_ranges = {
|
||||||
|
|
Loading…
Reference in a new issue