# Path: utils/checks.py
# class No_Owner(commands.CommandError): pass
# class No_Perms(commands.CommandError): pass
# class No_Role(commands.CommandError): pass
# class No_Admin(commands.CommandError): pass
# class No_Mod(commands.CommandError): pass
# class No_Sup(commands.CommandError): pass
# class No_ServerandPerm(commands.CommandError): pass
# class Nsfw(commands.CommandError): pass
# def is_owner_check(message):
# def is_owner():
# def check_permissions(ctx, perms):
# def role_or_perm(t, ctx, check, **perms):
# def mod_or_perm(**perms):
# 	def predicate(ctx):
# def admin_or_perm(**perms):
# 	def predicate(ctx):
# def is_in_servers(*server_ids):
# 	def predicate(ctx):
# def server_and_perm(ctx, *server_ids, **perms):
# def sup(ctx):
# def nsfw():
# 	def predicate(ctx):
# 
# Path: mods/cog.py
# class Cog(metaclass=CogMeta):
# 	def __init__(self, bot:NotSoBot):
# 		self._bot = bot
# 
# 	@property
# 	def bot(self):
# 		return self._bot
# 
# 	@classmethod
# 	def setup(cls, bot:NotSoBot):
# 		bot.add_cog(cls(bot))


import discord
import random
import json
import xml.etree.ElementTree
import aiohttp
import bs4
import sys
from io import BytesIO
from discord.ext import commands
from utils import checks
from mods.cog import Cog
from urllib.parse import quote
	def __init__(self, bot):
		super().__init__(bot)
		self.cursor = bot.mysql.cursor
		self.escape = bot.escape
		self.bytes_download = bot.bytes_download
		self.get_json = bot.get_json

	async def banned_tags(self, ctx, search):
		if ctx.message.channel.is_private:
			return False
		sql = 'SELECT * FROM banned_nsfw_tags WHERE server={0}'
		sql = sql.format(ctx.message.server.id)
		result = self.cursor.execute(sql).fetchall()
		tags = []
		for x in result:
			tags.append(x['tag'])
		found = []
		for tag in tags:
			for s in [x for x in search]:
				try:
					index = tags.index(str(s))
					found.append(tags[index])
				except (IndexError, ValueError):
					continue
		if len(found) != 0:
			await self.bot.send_message(ctx.message.channel, ':no_entry: Your search included banned tag(s): `{0}`'.format(', '.join(found)))
			return True
		return False

	@commands.group(pass_context=True, aliases=['bannsfwtag', 'bannsfwsearch', 'nsfwban'], invoke_without_command=True, no_pm=True)

# Path: utils/checks.py
# class No_Owner(commands.CommandError): pass
# class No_Perms(commands.CommandError): pass
# class No_Role(commands.CommandError): pass
# class No_Admin(commands.CommandError): pass
# class No_Mod(commands.CommandError): pass
# class No_Sup(commands.CommandError): pass
# class No_ServerandPerm(commands.CommandError): pass
# class Nsfw(commands.CommandError): pass
# def is_owner_check(message):
# def is_owner():
# def check_permissions(ctx, perms):
# def role_or_perm(t, ctx, check, **perms):
# def mod_or_perm(**perms):
# 	def predicate(ctx):
# def admin_or_perm(**perms):
# 	def predicate(ctx):
# def is_in_servers(*server_ids):
# 	def predicate(ctx):
# def server_and_perm(ctx, *server_ids, **perms):
# def sup(ctx):
# def nsfw():
# 	def predicate(ctx):
# 
# Path: mods/cog.py
# class Cog(metaclass=CogMeta):
# 	def __init__(self, bot:NotSoBot):
# 		self._bot = bot
# 
# 	@property
# 	def bot(self):
# 		return self._bot
# 
# 	@classmethod
# 	def setup(cls, bot:NotSoBot):
# 		bot.add_cog(cls(bot))


# Path: mods/Nsfw.py
import discord
import random
import json
import xml.etree.ElementTree
import aiohttp
import bs4
import sys
from io import BytesIO
from discord.ext import commands
from utils import checks
from mods.cog import Cog
from urllib.parse import quote

	def __init__(self, bot):
		super().__init__(bot)
		self.cursor = bot.mysql.cursor
		self.escape = bot.escape
		self.bytes_download = bot.bytes_download
		self.get_json = bot.get_json

	async def banned_tags(self, ctx, search):
		if ctx.message.channel.is_private:
			return False
		sql = 'SELECT * FROM banned_nsfw_tags WHERE server={0}'
		sql = sql.format(ctx.message.server.id)
		result = self.cursor.execute(sql).fetchall()
		tags = []
		for x in result:
			tags.append(x['tag'])
		found = []
		for tag in tags:
			for s in [x for x in search]:
				try:
					index = tags.index(str(s))
					found.append(tags[index])
				except (IndexError, ValueError):
					continue
		if len(found) != 0:
			await self.bot.send_message(ctx.message.channel, ':no_entry: Your search included banned tag(s): `{0}`'.format(', '.join(found)))
			return True
		return False

	@commands.group(pass_context=True, aliases=['bannsfwtag', 'bannsfwsearch', 'nsfwban'], invoke_without_command=True, no_pm=True)

	@checks.mod_or_perm(manage_server=True)