示例#1
0
        public void Next(IrcTrigger trigger)
        {
            string gameFormat = "{0} vs. {1}";
            string responseFormat = "Next game{0}: {1} - Kick off in {2}";

            string response = null;

            Game[] g = null;

            if (!string.IsNullOrEmpty(trigger.Message))
            {
                g = d.GetNextTeamGame(trigger.Message);
            }
            else
            {
                g = d.GetNextGames();
            }

            if (g !=null && g.Any())
            {
                //response = string.Format(responseFormat, g.TeamA.Name, g.TeamB.Name, Helpers.Time.ReadableDifference(g.DateTime));
                string games =  string.Join(", ", g.Select(q => string.Format(gameFormat, q.TeamA.Name, q.TeamB.Name)));
                response = string.Format(responseFormat, (g.Count() > 1 ? "s" : ""), games, Helpers.Time.ReadableDifference(g.First().DateTime));
            }
            else
            {
                response = "No games found.";
            }

            if (FunctionOutputHandler != null && response != null)
            {
                FunctionOutputHandler(SendType.Message, trigger.Channel, response);
            }
        }
示例#2
0
        public static bool Load(string trigger, IrcEventArgs e, out IrcTrigger ircTrigger)
        {
            ircTrigger = new IrcTrigger();

            Regex regex = new Regex(string.Format(triggerFormat, trigger), RegexOptions.IgnoreCase);

            Match m = regex.Match(e.Data.Message);

            if(m.Success)
            {
                ircTrigger.Channel = e.Data.Channel;
                ircTrigger.Nick = e.Data.Nick;
                ircTrigger.Host = e.Data.Host;
                ircTrigger.Message = m.Groups["args"].Value;
                ircTrigger.Arguments =
                    (ircTrigger.Message.Length > 0 ?
                        ircTrigger.Message.Split(new char[] { ' ' }) :
                        new string[0]
                    );
                ircTrigger.Trigger = m.Groups["trigger"].Value;
                return true;
            }

            return false;
        }
示例#3
0
        public void GetPlayer(IrcTrigger trigger)
        {
            string outputFormat = "{0} (#{1} for {2}) - Goals: {3} Fouls: {4} (" +
            Colour.MakeColour(Colour.RED, Colour.RED) + "R" + Colour.NORMAL + ":{5} - " +
            Colour.MakeColour(Colour.YELLOW, Colour.YELLOW) + "Y" + Colour.NORMAL + ":{6}) " +
            "Shots [on target]: {7} [{8}] " +
            "Passes [% complete]: {9} [{10}]";

            if (trigger.Arguments.Any())
            {
                Player p = searchPlayer(trigger.Message);

                if (p != null)
                {
                    if (p.HasData)
                    {
                        Output(trigger.Channel, string.Format(outputFormat, p.Name, p.KitNumber, p.Team, p.Goals, p.Fouls,
                                p.Reds, p.Yellows, p.Shots, p.ShotsOnTarget, p.Passes, p.PassCompletion));
                    }
                    else
                    {
                        Output(trigger.Channel, "I know who " + p.Name + " is, but I have no data for him.");
                    }
                }
                else
                {
                    Output(trigger.Channel, string.Format("No player by the name of {0} found", trigger.Message));
                }
            }
            else
            {
                Output(trigger.Channel, "No player specified");
            }
        }
示例#4
0
        public void GetGroupTable(IrcTrigger trigger)
        {
            if(trigger.Arguments.Any())
            {
                char group = trigger.Message.ToUpper()[0];

                JObject jsonObject = JObject.Parse(new System.Net.WebClient().DownloadString(URL_TABLES));

                JArray tables = (JArray)jsonObject["footballTables"]["table"];

                foreach (var table in tables)
                {

                    int tableID = table["round"]["number"].Value<int>()-1;

                    if (Tables[tableID]== group)
                    {
                        string[] lines = FormatGroupTable(Tables[tableID], (JObject)table).Split(new string[]{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);

                        foreach(string line in lines)
                        {
                            FunctionOutputHandler(Meebey.SmartIrc4net.SendType.Message, trigger.Channel, line);
                        }
                    }

                }
            }
        }
示例#5
0
        public void Dev(IrcTrigger trigger)
        {
            if (trigger.Arguments.Any())
            {
                switch (trigger.Arguments[0].ToLower())
                {
                    case "about":
                        Output(trigger.Channel, "Zakumi is written in C#/.NET from the ground up and is based on the Meebey SmartIRC4Net framework");
                        break;

                    case "issue":
                        Output(trigger.Channel, "Report/track issues at http://github.com/BauerUK/WorldCupBot/issues or in #worldcup-dev");
                        break;

                    case "wiki":
                        Output(trigger.Channel, "WorldCupBot wiki: http://wiki.github.com/BauerUK/WorldCupBot/");
                        break;

                    case "git":
                        Output(trigger.Channel, "git repo: [email protected]:BauerUK/WorldCupBot.git");
                        break;

                    case "github":
                        Output(trigger.Channel, "WorldCupBot github page: http://github.com/BauerUK/WorldCupBot");
                        break;

                }
            }
            else
            {
                Output(trigger.Channel, "Join #worldcup-dev for developer information/bugs/feature reports, etc.");
            }
        }
示例#6
0
        public void Today(IrcTrigger trigger)
        {
            string responseFormat = "Games for {0}: {1}";
            string response = null;

            DateTime searchFor = new DateTime();

            bool success = false;

            if (trigger.Message != string.Empty)
            {
                try
                {
                    string message = trigger.Message.ToLower().Replace("tomorrow", "in 1 day");
                    var d = Helpers.Time.ParseDate(message);
                    searchFor = d.Dates.Last();
                    success = true;
                }
                catch
                {
                    success = false;
                }
            }
            else
            {
                searchFor = DateTime.UtcNow;
                success = true;
            }

            if (success)
            {
                var games = d.GetGamesByDate(searchFor);

                if (games.Any())
                {

                    List<string> gameList = games.Select(g =>
                                string.Concat("[", Colour.BOLD, g.DateTime.AddHours(2).ToShortTimeString(), Colour.NORMAL, "] ", g.TeamA.Name,
                                (g.HasScore ? (string.Concat(" ", g.TeamAScore, " - ", g.TeamBScore , " ") ) : " v "), g.TeamB.Name)).ToList();

                    string lastGame = gameList[gameList.Count - 1];

                    gameList[gameList.Count - 1] = "and " + lastGame;

                    response = string.Format(responseFormat, searchFor.ToShortDateString(),
                        string.Join("; ", gameList));
                }
                else
                {
                    response = "No games for " + searchFor.ToShortDateString();
                }
            }
            else
            {
                response = "Unable to find games for that date. Did you enter a real date?";
            }

            if (FunctionOutputHandler != null)
            {
                FunctionOutputHandler(SendType.Message, trigger.Channel, response);
            }
        }