Exemplo n.º 1
0
        private IEnumerable <string> LastGameLineScore(int teamId)
        {
            List <string> result = new List <string>();

            var api      = new NHLApiClient();
            var lastGame = api.GetLastGame(teamId);
            var teamData = api.GetTeam(teamId);

            if (lastGame == null || lastGame.TotalGames < 1)
            {
                result.Add(string.Format("There are currently no previous games the {0}", teamData.Name));
                return(result);
            }

            var homeTeam  = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Home.Team.Id);
            var awayTeam  = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Away.Team.Id);
            var gameData  = api.GetLiveGameDetail(lastGame.Dates[0].Games[0].GamePk);
            var lineScore = api.GetGameLineScore(lastGame.Dates[0].Games[0].GamePk);

            foreach (var period in lineScore.Periods)
            {
                var summary = NHLInformationSummarizer.PeriodSummary(period, homeTeam, awayTeam, gameData);
                result.Add(summary.ToString());
            }
            return(result);
        }
Exemplo n.º 2
0
        private void SendLineScoreForPeriod(JObject gameObj)
        {
            List <string> result = new List <string>();

            var api = new NHLApiClient();

            var homeTeam  = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["home"]["id"].ToString()));
            var awayTeam  = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["away"]["id"].ToString()));
            var gameData  = api.GetLiveGameDetail(int.Parse(gameObj["gamePk"].ToString()));
            var lineScore = api.GetGameLineScore(int.Parse(gameObj["gamePk"].ToString()));

            _channel.SendMessageAsync(NHLInformationSummarizer.PeriodSummary(lineScore.Periods.Last(), homeTeam, awayTeam, gameData));
        }
Exemplo n.º 3
0
        private void SendGameSummary(JObject gameObj)
        {
            List <string> result = new List <string>();

            var api = new NHLApiClient();

            var teamId       = _config.Team;
            var scheduleData = api.GetTodaysSchedule(teamId);
            var nextGame     = api.GetNextGame(teamId);
            var teamData     = api.GetTeam(teamId);

            _channel.SendMessageAsync(NHLInformationSummarizer.GameSummary(scheduleData, nextGame, teamData));
        }
Exemplo n.º 4
0
        private void SendLineScoreForPeriod(JObject gameObj)
        {
            List <string> result = new List <string>();

            var api = new NHLApiClient();

            var homeTeam  = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["home"]["id"].ToString()));
            var awayTeam  = api.GetTeam(int.Parse(gameObj["gameData"]["teams"]["away"]["id"].ToString()));
            var gameData  = api.GetLiveGameDetail(int.Parse(gameObj["gamePk"].ToString()));
            var lineScore = api.GetGameLineScore(int.Parse(gameObj["gamePk"].ToString()));

            Locator.Instance.Fetch <ILogger>().LogLine(String.Format("Goal Horn: Sending period line score for {0}", _config.TeamFriendlyName));
            _channel.SendMessageAsync(NHLInformationSummarizer.PeriodSummary(lineScore.Periods.Last(), homeTeam, awayTeam, gameData));
        }
Exemplo n.º 5
0
        private IEnumerable <string> LastGameLineScore(string team)
        {
            Locator.Instance.Fetch <ILogger>().LogLine("Executing LastGameLineScore command for: " + team);
            List <string> result = new List <string>();
            int           teamId = -1;

            var isTeamId = int.TryParse(team, out teamId);

            if (!isTeamId)
            {
                var Ids = Locator.Instance.Fetch <TeamNameTranslator>().LookupIdsForName(team);
                if (Ids.Count > 1)
                {
                    result.Add("Name conflict, got more than one team ID for " + team + ". Please be more specific.");
                    return(result);
                }

                if (Ids.Count == 0)
                {
                    result.Add("Couldn't find a team by the name " + team + ". Please try another name.");
                    return(result);
                }

                teamId = Ids.First().Key;
            }

            var api      = new NHLApiClient();
            var lastGame = api.GetLastGame(teamId);
            var teamData = api.GetTeam(teamId);

            if (lastGame == null || lastGame.TotalGames < 1)
            {
                result.Add(string.Format("There are currently no previous games the {0}", teamData.Name));
                return(result);
            }

            var homeTeam  = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Home.Team.Id);
            var awayTeam  = api.GetTeam(lastGame.Dates[0].Games[0].Teams.Away.Team.Id);
            var gameData  = api.GetLiveGameDetail(lastGame.Dates[0].Games[0].GamePk);
            var lineScore = api.GetGameLineScore(lastGame.Dates[0].Games[0].GamePk);

            foreach (var period in lineScore.Periods)
            {
                var summary = NHLInformationSummarizer.PeriodSummary(period, homeTeam, awayTeam, gameData);
                result.Add(summary.ToString());
            }
            return(result);
        }
Exemplo n.º 6
0
        private IEnumerable <string> NextGame(int team)
        {
            List <string> result   = new List <string>();
            NHLApiClient  api      = new NHLApiClient();
            var           nextGame = api.GetNextGame(team);
            var           teamData = api.GetTeam(team);

            if (nextGame.TotalGames < 1)
            {
                result.Add(string.Format("There are currently no games scheduled for the {0}", teamData.Name));
                return(result);
            }

            result.Add(NHLInformationSummarizer.NextGameSummary(nextGame, teamData));
            return(result);
        }
Exemplo n.º 7
0
        private IEnumerable <string> NextGame(string team)
        {
            Locator.Instance.Fetch <ILogger>().LogLine("Executing NextGame command for team: " + team);
            List <string> result = new List <string>();
            NHLApiClient  api    = new NHLApiClient();
            int           teamId = -1;

            var isTeamId = int.TryParse(team, out teamId);

            if (!isTeamId)
            {
                var Ids = Locator.Instance.Fetch <TeamNameTranslator>().LookupIdsForName(team);
                if (Ids.Count > 1)
                {
                    result.Add("Name conflict, got more than one team ID for " + team + ". Please be more specific.");
                    return(result);
                }

                if (Ids.Count == 0)
                {
                    result.Add("Couldn't find a team by the name " + team + ". Please try another name.");
                    return(result);
                }

                teamId = Ids.First().Key;
            }

            var nextGame = api.GetNextGame(teamId);
            var teamData = api.GetTeam(teamId);

            if (nextGame.TotalGames < 1)
            {
                result.Add(string.Format("There are currently no games scheduled for the {0}", teamData.Name));
                return(result);
            }

            result.Add(NHLInformationSummarizer.NextGameSummary(nextGame, teamData));
            return(result);
        }