# Path: Cogs/Nullify.py
# def setup(bot):
# def clean(string, deaden_links = False, ctx = None):
# def escape_all(string, mentions = True, markdown = True):
# def resolve_mentions(string, ctx = None, escape = True, show_mentions = True, channel_mentions = False):


import asyncio, discord, re
from   discord.ext import commands
from   Cogs import Nullify


# bot = None
# url_regex = re.compile(r"(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?")

def setup(bot):
	# This module isn't actually a cog - but it is a place
	# we can call "a trash fire"
	bot.add_cog(Utils(bot))
	# global bot
	# bot = bot_start

class Utils(commands.Cog):
	def __init__(self,bot):
		self.bot = bot
		self.url_regex = re.compile(r"(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?")

	def suppressed(self,ctx,msg,force=False):
		# Checks if the passed server is suppressing user/role mentions and adjust the msg accordingly
		guild = ctx if isinstance(ctx,discord.Guild) else ctx.guild if hasattr(ctx,"guild") else None
		if not guild: return msg
		settings = self.bot.get_cog("Settings")
		if not settings: return msg

# Path: Cogs/Nullify.py
# def setup(bot):
# def clean(string, deaden_links = False, ctx = None):
# def escape_all(string, mentions = True, markdown = True):
# def resolve_mentions(string, ctx = None, escape = True, show_mentions = True, channel_mentions = False):


# Path: Cogs/Utils.py
import asyncio, discord, re
from   discord.ext import commands
from   Cogs import Nullify


# bot = None
# url_regex = re.compile(r"(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?")

def setup(bot):
	# This module isn't actually a cog - but it is a place
	# we can call "a trash fire"
	bot.add_cog(Utils(bot))
	# global bot
	# bot = bot_start

class Utils(commands.Cog):
	def __init__(self,bot):
		self.bot = bot
		self.url_regex = re.compile(r"(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?")

	def suppressed(self,ctx,msg,force=False):
		# Checks if the passed server is suppressing user/role mentions and adjust the msg accordingly
		guild = ctx if isinstance(ctx,discord.Guild) else ctx.guild if hasattr(ctx,"guild") else None
		if not guild: return msg
		settings = self.bot.get_cog("Settings")
		if not settings: return msg

		return Nullify.clean(msg, ctx=guild) if (force or settings.getServerStat(guild, "SuppressMentions", True)) else msg
