def __init__(self): self.sentCache = {} self.checkingThread = threading.Thread(target = self.startThread) #self.checkingThread.daemon = True self.keepChecking = True self.config = Config() if self.config.winning_streak: self.winning_streak_messages = self.read_spree_file(self.config.winning_streak_file) if self.config.losing_streak: self.losing_streak_messages = self.read_spree_file(self.config.losing_streak_file) # Debug purposes self.printOutput = False # Initializing the API key = dotamatch.get_key() # Steam Dev Key (~/.steamapi) try: self.match_history = MatchHistory(key) self.match_details = MatchDetails(key) self.account_details = PlayerSummaries(key) self.heroes = Heroes(key).heroes() # ActualDB db = TinyDB(self.config.db_path) #db.purge() #db.purge_tables() self.matches_table = db.table('matches') self.matches_info_table = db.table('matches_info') except dotamatch.api.ApiError: print u"Erro ao conectar à API."
def __init__(self): self.client = MongoClient(os.environ['MONGO_URL']) self.db = self.client.dota2stats self.matches = self.db.matches self.preferences = self.db.preferences # Store key in ~/.steamapi self.key = get_key() self.matches.create_index([("match_id", ASCENDING)], unique=True)
from dotamatch import get_key from dotamatch.history import MatchHistory from dotamatch.matches import MatchDetails from dotamatch.players import PlayerSummaries from dotamatch.heroes import Heroes key = get_key() history = MatchHistory(key) player_summaries = PlayerSummaries(key) details = MatchDetails(key) heroes = Heroes(key) tidehunter_id = 29 for match in history.matches(skill=3, hero_id=tidehunter_id): match = details.match(match.match_id) for player in [p for p in match.players if p["hero_id"] == tidehunter_id]: for i in range(6): print("item_{0}".format(i), player["item_{0}".format(i)])
from dotamatch import get_key from dotamatch.history import MatchHistory from dotamatch.matches import MatchDetails from dotamatch.players import PlayerSummaries from dotamatch.heroes import Heroes key = get_key() history = MatchHistory(key) player_summaries = PlayerSummaries(key) details = MatchDetails(key) heroes = Heroes(key) tidehunter_id = 29 for match in history.matches(skill=3, hero_id=tidehunter_id): match = details.match(match.match_id) for player in [p for p in match.players if p['hero_id'] == tidehunter_id]: for i in range(6): print 'item_{0}'.format(i), player['item_{0}'.format(i)]
# -*- coding: utf-8 -*- from datetime import timedelta from datetime import datetime from tinydb import TinyDB import pytz from config import Config import dotamatch from dotamatch import MatchDetails from dotamatch import MatchHistory from dotamatch import PlayerSummaries from dotamatch import Heroes c = Config() key = dotamatch.get_key() match_history = MatchHistory(key) match_details = MatchDetails(key) account_details = PlayerSummaries(key) heroes = Heroes(key).heroes() def calculate_status(info): if info['win']: return "venceu" else: return "perdeu" def utc_to_local(time): local_tz = pytz.timezone(c.timezone) local_dt = datetime.fromtimestamp(time, local_tz) if c.ignore_dst: