# Path: cogs/utils/drawdota.py
# def get_item_color(item, default=None):
# def init_dota_info(hero_info, item_info, ability_info, the_vpkurl):
# def get_hero_name(hero_id):
# async def get_url_image(url):
# async def get_hero_image(hero_id):
# async def get_hero_icon(hero_id):
# async def get_hero_portrait(hero_id):
# async def get_item_image(item_id):
# async def get_level_image(level):
# async def get_ability_image(ability_id, hero_id=None):
# async def get_talents_image(abilities, hero_id):
# async def get_neutral_image(item):
# async def get_active_aghs_image(player):
# async def get_item_images(player):
# async def get_spell_images(spells):
# def get_lane(player):
# async def add_player_row(table, player, is_parsed, is_ability_draft, has_talents):
# 		def ad_ability_filter(ability_id):
# async def draw_match_table(match):
# async def create_match_image(match):
# async def combine_image_halves(img_url1, img_url2):
# def optimize_gif(uri, filename):
# def place_icon_on_map(map_image, icon, x, y):
# async def create_dota_gif(bot, match, stratz_match, start_time, end_time, ms_per_second=100):
# def create_dota_gif_main(match, stratz_match, start_time, end_time, ms_per_second, filename, uri, hero_icons):
# async def create_dota_emoticon(emoticon, url):
# async def dota_rank_icon(rank_tier, leaderboard_rank):
# def get_datetime_cell(match, region_data):
# async def draw_meta_table(sorted_heroes, heroes): 
# async def draw_matches_table(matches, game_strings):
# async def draw_hero_talents(hero):
# async def fuse_hero_images(hero1, hero2):
# async def draw_courage(hero_id, icon_ids):
# async def draw_artifact_deck(deck_string, cards, hero_turns, card_counts):
# def grouper(values, N):
# async def draw_neutralitems_tier(selected_tier, all_neutral_items):
# async def draw_neutralitems(selected_tier, all_neutral_items):
# def get_poly_points(n, radius, origin=(0, 0), radius_percentages=None):
# def draw_poly_label(draw, point, center, text):
# def draw_polygraph(values, labels):
# async def draw_herostatstable(table_args, hero_stat_categories, leveled_hero_stats):
# async def draw_itemrecipe(main_item, components, products):
# async def draw_heroabilities(abilities):
# async def add_player_ability_upgrades_row(table, player):
# async def draw_match_ability_upgrades(match):
# 
# Path: cogs/utils/imagetools.py
# def rgb_to_hsv(rgb):
# def hsv_to_rgb(hsv):
# 	def __init__(self, value):
# 	def integer(self):
# 	def hex(self):
# 	def rgb_tuple(self):
# 	def hsv_tuple(self):
# 	def h(self):
# 	def s(self):
# 	def v(self):
# 	def rgba_tuple(self, a):
# 	def __repr__(self):
# 	def __eq__(self, other):
# 	def __hash__(self):
# 	def blend(self, color, opacity=0.5):
# def color_diff(c1, c2):
# def colorize_single(converter, pixel_color):
# def colorize_image(filename1, filename2, out_filename):
# def paste_image(image1, image2, x=0, y=0):
# def color_image(image, color):
# def remove_semi_transparent(image, color):
# def outline_image(image, thickness, color):
# class Color():
# 
# Path: cogs/utils/rsstools.py
# def is_new_blog(entry):
# def create_embed(blog_title, entry):
# 
# Path: cogs/audio.py
# class AudioPlayerNotFoundError(UserError):
# 	def __init__(self, message):
# 		super().__init__(message)


import disnake
import feedparser
import random
import os
import asyncio
import string
import re
import json
import logging
from disnake.ext import commands, tasks
from sqlalchemy.sql.expression import func
from sqlalchemy import and_, or_, desc
from __main__ import settings, httpgetter
from cogs.utils.helpers import *
from cogs.utils.clip import *
from cogs.utils.commandargs import *
from cogs.utils import drawdota, imagetools
from cogs.utils import rsstools
from .mangocog import *
from dotabase import *
from cogs.audio import AudioPlayerNotFoundError
		for var in variables:
			if (var.value is None) and (word in var.aliases):
				var.value = var.aliases[word]
				words.remove(word)
				return True
	return False

# Filters a query for rows containing a column that contains the value in a | separated list
def query_filter_list(query, column, value, separator="|"):
	return query.filter(or_(column.like(f"%|{value}"), column.like(f"{value}|%"), column.like(f"%|{value}|%"), column.like(value)))


class Dotabase(MangoCog):
	"""For information about Dota 2, and playing hero responses

	Interfaces with [dotabase](http://github.com/mdiller/dotabase). Check out [dotabase.dillerm.io](http://dotabase.dillerm.io) if you want to see a website that interfaces with dotabase."""
	def __init__(self, bot):
		MangoCog.__init__(self, bot)
		self.session = session
		self.criteria_aliases = read_json(settings.resource("json/criteria_aliases.json"))
		self.hero_stat_categories = read_json(settings.resource("json/hero_stats.json"))
		self.hero_aliases = {}
		self.item_aliases = {}
		self.leveled_hero_stats = [] # by level (0 is null, and 1-30 are filled in)
		self.hero_regex = ""
		self.item_regex_1 = ""
		self.item_regex_2 = ""
		self.patches_regex = ""
		self.build_helpers()
		self.vpkurl = "http://dotabase.dillerm.io/dota-vpk"

# Path: cogs/utils/drawdota.py
# def get_item_color(item, default=None):
# def init_dota_info(hero_info, item_info, ability_info, the_vpkurl):
# def get_hero_name(hero_id):
# async def get_url_image(url):
# async def get_hero_image(hero_id):
# async def get_hero_icon(hero_id):
# async def get_hero_portrait(hero_id):
# async def get_item_image(item_id):
# async def get_level_image(level):
# async def get_ability_image(ability_id, hero_id=None):
# async def get_talents_image(abilities, hero_id):
# async def get_neutral_image(item):
# async def get_active_aghs_image(player):
# async def get_item_images(player):
# async def get_spell_images(spells):
# def get_lane(player):
# async def add_player_row(table, player, is_parsed, is_ability_draft, has_talents):
# 		def ad_ability_filter(ability_id):
# async def draw_match_table(match):
# async def create_match_image(match):
# async def combine_image_halves(img_url1, img_url2):
# def optimize_gif(uri, filename):
# def place_icon_on_map(map_image, icon, x, y):
# async def create_dota_gif(bot, match, stratz_match, start_time, end_time, ms_per_second=100):
# def create_dota_gif_main(match, stratz_match, start_time, end_time, ms_per_second, filename, uri, hero_icons):
# async def create_dota_emoticon(emoticon, url):
# async def dota_rank_icon(rank_tier, leaderboard_rank):
# def get_datetime_cell(match, region_data):
# async def draw_meta_table(sorted_heroes, heroes): 
# async def draw_matches_table(matches, game_strings):
# async def draw_hero_talents(hero):
# async def fuse_hero_images(hero1, hero2):
# async def draw_courage(hero_id, icon_ids):
# async def draw_artifact_deck(deck_string, cards, hero_turns, card_counts):
# def grouper(values, N):
# async def draw_neutralitems_tier(selected_tier, all_neutral_items):
# async def draw_neutralitems(selected_tier, all_neutral_items):
# def get_poly_points(n, radius, origin=(0, 0), radius_percentages=None):
# def draw_poly_label(draw, point, center, text):
# def draw_polygraph(values, labels):
# async def draw_herostatstable(table_args, hero_stat_categories, leveled_hero_stats):
# async def draw_itemrecipe(main_item, components, products):
# async def draw_heroabilities(abilities):
# async def add_player_ability_upgrades_row(table, player):
# async def draw_match_ability_upgrades(match):
# 
# Path: cogs/utils/imagetools.py
# def rgb_to_hsv(rgb):
# def hsv_to_rgb(hsv):
# 	def __init__(self, value):
# 	def integer(self):
# 	def hex(self):
# 	def rgb_tuple(self):
# 	def hsv_tuple(self):
# 	def h(self):
# 	def s(self):
# 	def v(self):
# 	def rgba_tuple(self, a):
# 	def __repr__(self):
# 	def __eq__(self, other):
# 	def __hash__(self):
# 	def blend(self, color, opacity=0.5):
# def color_diff(c1, c2):
# def colorize_single(converter, pixel_color):
# def colorize_image(filename1, filename2, out_filename):
# def paste_image(image1, image2, x=0, y=0):
# def color_image(image, color):
# def remove_semi_transparent(image, color):
# def outline_image(image, thickness, color):
# class Color():
# 
# Path: cogs/utils/rsstools.py
# def is_new_blog(entry):
# def create_embed(blog_title, entry):
# 
# Path: cogs/audio.py
# class AudioPlayerNotFoundError(UserError):
# 	def __init__(self, message):
# 		super().__init__(message)


# Path: cogs/dotabase.py
import disnake
import feedparser
import random
import os
import asyncio
import string
import re
import json
import logging
from disnake.ext import commands, tasks
from sqlalchemy.sql.expression import func
from sqlalchemy import and_, or_, desc
from __main__ import settings, httpgetter
from cogs.utils.helpers import *
from cogs.utils.clip import *
from cogs.utils.commandargs import *
from cogs.utils import drawdota, imagetools
from cogs.utils import rsstools
from .mangocog import *
from dotabase import *
from cogs.audio import AudioPlayerNotFoundError

		for var in variables:
			if (var.value is None) and (word in var.aliases):
				var.value = var.aliases[word]
				words.remove(word)
				return True
	return False

# Filters a query for rows containing a column that contains the value in a | separated list
def query_filter_list(query, column, value, separator="|"):
	return query.filter(or_(column.like(f"%|{value}"), column.like(f"{value}|%"), column.like(f"%|{value}|%"), column.like(value)))


class Dotabase(MangoCog):
	"""For information about Dota 2, and playing hero responses

	Interfaces with [dotabase](http://github.com/mdiller/dotabase). Check out [dotabase.dillerm.io](http://dotabase.dillerm.io) if you want to see a website that interfaces with dotabase."""
	def __init__(self, bot):
		MangoCog.__init__(self, bot)
		self.session = session
		self.criteria_aliases = read_json(settings.resource("json/criteria_aliases.json"))
		self.hero_stat_categories = read_json(settings.resource("json/hero_stats.json"))
		self.hero_aliases = {}
		self.item_aliases = {}
		self.leveled_hero_stats = [] # by level (0 is null, and 1-30 are filled in)
		self.hero_regex = ""
		self.item_regex_1 = ""
		self.item_regex_2 = ""
		self.patches_regex = ""
		self.build_helpers()
		self.vpkurl = "http://dotabase.dillerm.io/dota-vpk"

		drawdota.init_dota_info(self.get_hero_infos(), self.get_item_infos(), self.get_ability_infos(), self.vpkurl)