# Path: botcommands/averagelastxgames.py
# def averageLastXGames(playerID, amount=100, detailedAnalysis=False, heroID=None, gameModeID=None, tournamentGamesOnly=False, getMMR=True):
# def analyzeMatches(playerID, detailedMatches):
# def addStatsTogether(storage, player, addTogether):
# def testBit(int_type, offset):
# def amountOfTowersDestroyed(tower_status):
# def amountOfBarracksDestroyed(barracks_status):
# 
# Path: botcommands/match.py
# def match(matchID):
# 
# 
#     t = threading.Thread(target=requestparsematch.requestParseMatch, args = (matchID,))
#     t.start()
# 
#     matchJson = getmatchdetails.getMatchDetails(matchID)
# 
#     accountIDs = []
#     for player in matchJson['result']['players']:
#         accountIDs.append(player['account_id'])
# 
#     playerSummariesJson = getplayersummaries.getPlayerSummaries(accountIDs)
# 
#     reply = drmatch.displayResult(matchJson, playerSummariesJson)
# 
#     return reply
# 
# Path: botcommands/odotachat.py
# def odotaChat(matchID):
# 
# Path: steamapi/getheroes.py
# def requestGetHeroes():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=" + SteamAPIKey + "&language=en_us"
# 
# Path: reddit/botinfo.py

# 
# Path: steamapi/getheroes.py
# def requestGetHeroes():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=" + SteamAPIKey + "&language=en_us"


from botcommands import averagelastxgames, match, odotachat
from steamapi import getheroes
from reddit.botinfo import message,botName
from steamapi import getheroes
import time
import re
                            n = re.search(patternHero, queryParameters, re.I)
                            if n != None:
                                heroID = n.group('heroID')
                                reverseDBHeroDictionary = {v:k for k,v in getheroes.heroDictionaryDotabuff.items()}
                                heroID = reverseDBHeroDictionary[heroID]
                        except:
                            print('[workeranalyzecontent] Dotabuff hero filtering crashed, needs investigation')

                    try:
                        partialReply += str(averagelastxgames.averageLastXGames(int(playerID), amount=100, detailedAnalysis=False, heroID=heroID, gameModeID=gameModeID, getMMR=True))
                        commandCounter += 1
                        analyzedPlayers.append(playerID)
                    except:
                        print('[workeranalyzecontent] Could not analyze player.')
            else:
                break
    except:
        print('[workeranalyzecontent] failed to average last x games on')

    try:
        pattern = '(yasp\.co|dotabuff\.com|opendota\.com)\/matches\/(?P<matchID>\d{1,10})(\/(?P<tab>\w+))?'

        for m in re.finditer(pattern, text, re.I):
            if commandCounter < 3:                      #Reddit has character limit, only have room for 3 match analysis
                matchID = m.group('matchID')
                tab = m.group('tab')
                if matchID not in analyzedMatches:
                    if tab == 'chat':
                        partialReply += str(odotachat.odotaChat(matchID))
                    else:

# Path: botcommands/averagelastxgames.py
# def averageLastXGames(playerID, amount=100, detailedAnalysis=False, heroID=None, gameModeID=None, tournamentGamesOnly=False, getMMR=True):
# def analyzeMatches(playerID, detailedMatches):
# def addStatsTogether(storage, player, addTogether):
# def testBit(int_type, offset):
# def amountOfTowersDestroyed(tower_status):
# def amountOfBarracksDestroyed(barracks_status):
# 
# Path: botcommands/match.py
# def match(matchID):
# 
# 
#     t = threading.Thread(target=requestparsematch.requestParseMatch, args = (matchID,))
#     t.start()
# 
#     matchJson = getmatchdetails.getMatchDetails(matchID)
# 
#     accountIDs = []
#     for player in matchJson['result']['players']:
#         accountIDs.append(player['account_id'])
# 
#     playerSummariesJson = getplayersummaries.getPlayerSummaries(accountIDs)
# 
#     reply = drmatch.displayResult(matchJson, playerSummariesJson)
# 
#     return reply
# 
# Path: botcommands/odotachat.py
# def odotaChat(matchID):
# 
# Path: steamapi/getheroes.py
# def requestGetHeroes():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=" + SteamAPIKey + "&language=en_us"
# 
# Path: reddit/botinfo.py

# 
# Path: steamapi/getheroes.py
# def requestGetHeroes():
#     URL = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=" + SteamAPIKey + "&language=en_us"


# Path: reddit/workeranalyzecontent.py
from botcommands import averagelastxgames, match, odotachat
from steamapi import getheroes
from reddit.botinfo import message,botName
from steamapi import getheroes
import time
import re

                            n = re.search(patternHero, queryParameters, re.I)
                            if n != None:
                                heroID = n.group('heroID')
                                reverseDBHeroDictionary = {v:k for k,v in getheroes.heroDictionaryDotabuff.items()}
                                heroID = reverseDBHeroDictionary[heroID]
                        except:
                            print('[workeranalyzecontent] Dotabuff hero filtering crashed, needs investigation')

                    try:
                        partialReply += str(averagelastxgames.averageLastXGames(int(playerID), amount=100, detailedAnalysis=False, heroID=heroID, gameModeID=gameModeID, getMMR=True))
                        commandCounter += 1
                        analyzedPlayers.append(playerID)
                    except:
                        print('[workeranalyzecontent] Could not analyze player.')
            else:
                break
    except:
        print('[workeranalyzecontent] failed to average last x games on')

    try:
        pattern = '(yasp\.co|dotabuff\.com|opendota\.com)\/matches\/(?P<matchID>\d{1,10})(\/(?P<tab>\w+))?'

        for m in re.finditer(pattern, text, re.I):
            if commandCounter < 3:                      #Reddit has character limit, only have room for 3 match analysis
                matchID = m.group('matchID')
                tab = m.group('tab')
                if matchID not in analyzedMatches:
                    if tab == 'chat':
                        partialReply += str(odotachat.odotaChat(matchID))
                    else:

                        partialReply += str(match.match(matchID))