New logging

This commit is contained in:
Logan Cusano
2022-03-28 01:27:37 -04:00
parent d97e51d960
commit c741288b87
7 changed files with 158 additions and 95 deletions

View File

@@ -1,3 +1,4 @@
import logging
import re
import discord
from discord.ext import commands
@@ -26,6 +27,8 @@ random_message = ["{%mtn_user%}, tsk tsk. Links belong here:\n{%ref_og_msg%}", "
# welcome 757379843792044102
# the-round-table 367396189529833474
LOGGER = logging.getLogger("Discord_Radio_Bot.LinkCop")
class LinkCop(commands.Cog):
def __init__(self, bot):
self.bot = bot
@@ -59,7 +62,7 @@ class LinkCop(commands.Cog):
try:
if not any(item.id in self.whitelisted_groups for item in ctx.author.roles):
if check_message(ctx.content):
print('Msg with links detected in a blocked channel')
LOGGER.info('Msg with links detected in a blocked channel')
response_text = self.generate_response(ctx)
@@ -68,8 +71,8 @@ class LinkCop(commands.Cog):
# 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")
LOGGER.error(f"Link Cop Error: '{err}'\nBot or other non-user that has not "
f"been whitelisted sent a message")
await check_and_reply_to_ping(self.bot, ctx)
@@ -123,7 +126,7 @@ def check_message(message_text):
def get_links(message_text):
links = regex_link.findall(message_text)
print(links)
LOGGER.error(links)
if len(links) > 0:
return links