def handle(text, mic, profile): """ Returns: the current score of the game of the supported team from the profile """ if "Liveticker" in profile: if "team" in profile["Liveticker"] and "league" in profile["Liveticker"]: #retrieve the supported team team = profile["Liveticker"]["team"] #retrieve the league of the supported team league = profile["Liveticker"]["league"] lt = Liveticker(team, league) match_data = lt.get_match_data() if match_data: home_team = Liveticker.get_team(match_data, 1) away_team = Liveticker.get_team(match_data, 2) home_score = Liveticker.get_goals(match_data, 1) away_score = Liveticker.get_goals(match_data, 2) if match_data["MatchIsFinished"]: output = "Match finished! %s against %s ... %s to %s." % (home_team, away_team, home_score, away_score) else: output = "Goal! New score in the game %s against %s ... %s to %s." % (home_team, away_team, home_score, away_score) mic.say(output) else: mic.say("Error while reading your profile. Make sure you have set your supported team and it's league set correctly.") else: mic.say("Error. You have to specify a supported team and it's league in your profile.") else: mic.say("Error. To use the liveticker functionality, specify a supported team and it's league in your profile.")
def handleLivetickerNotifications(self, latest): """ Gets the new goal from the game and places it in the Notifier's queue. latest is the last goal ID """ team = self.profile["Liveticker"]["team"] league = self.profile["Liveticker"]["league"] lt = Liveticker(team, league) match_data = lt.get_match_data() if match_data: last_goal = Liveticker.get_last_goal(match_data) if last_goal["GoalID"] > latest: self.q.put(Liveticker.format_goal(last_goal)) latest = last_goal["GoalID"] return latest