bugfixes for LinkCop
This commit is contained in:
@@ -19,6 +19,10 @@ random_message = ["{%mtn_user%}, tsk tsk. Links belong here:\n{%ref_og_msg%}", "
|
||||
"{%mtn_user%}, isn't this convenient. A whole channel for links and you put links in, and you put {%ref_first_link_%} in {%ref_og_channel%}.\n\n'{%ref_og_msg%}'",
|
||||
]
|
||||
|
||||
### Channel IDs
|
||||
# testing 918029426397184000
|
||||
# links 767303243285790721
|
||||
|
||||
class LinkCop(commands.Cog):
|
||||
def __init__(self, bot): # , mention_group='Superadmins', channel_id=757379843792044102):
|
||||
self.bot = bot
|
||||
@@ -29,24 +33,44 @@ class LinkCop(commands.Cog):
|
||||
767303243285790721
|
||||
]
|
||||
|
||||
self.whitelisted_groups = [
|
||||
757375638926655709, # Superadmins
|
||||
758792783020163084 # Bots
|
||||
]
|
||||
|
||||
self.whitelisted_ID = [
|
||||
756327271597473863, # Greada ID
|
||||
915064996994633729, # Jorn ID
|
||||
235148962103951360 # Carl Bot
|
||||
]
|
||||
|
||||
self.add_events()
|
||||
|
||||
def add_events(self):
|
||||
@self.bot.event
|
||||
async def on_message(ctx):
|
||||
### TODO check if user is an admin
|
||||
if self.bot.user.id not in self.whitelisted_ID:
|
||||
self.whitelisted_ID.append(self.bot.user.id)
|
||||
|
||||
if not ctx.author.id == self.bot.user.id:
|
||||
if ctx.channel.id in self.blocked_channels:
|
||||
if check_message(ctx.content):
|
||||
print('Msg with links detected in a blocked channel')
|
||||
print(self.whitelisted_ID)
|
||||
print(ctx.author.id)
|
||||
|
||||
response_text = self.generate_response(ctx)
|
||||
if ctx.author.id not in self.whitelisted_ID:
|
||||
try:
|
||||
if not any(item.id in self.whitelisted_groups for item in ctx.author.roles):
|
||||
if ctx.channel.id in self.blocked_channels:
|
||||
if check_message(ctx.content):
|
||||
print('Msg with links detected in a blocked channel')
|
||||
|
||||
# Send the response in the links channel
|
||||
await self.send_message(response_text)
|
||||
# Delete the original message
|
||||
await ctx.delete()
|
||||
response_text = self.generate_response(ctx)
|
||||
|
||||
# Send the response in the links channel
|
||||
await self.send_message(response_text)
|
||||
# Delete the original message
|
||||
await ctx.delete()
|
||||
except AttributeError as err:
|
||||
print(f"Link Cop Error: '{err}'")
|
||||
print(f"Bot or other non-user that has not been whitelisted sent a message")
|
||||
|
||||
async def send_message(self, message):
|
||||
send_channel = self.bot.get_channel(id=self.reply_channel_id)
|
||||
|
||||
Reference in New Issue
Block a user