Ejemplo n.º 1
0
        public void Setup(IRobot robot)
        {
            var settings = robot.Settings.SettingsFor<RouteTestAdapter>();

            var room = (string) settings.Settings.Room;

            robot.AddRoute(RouteMethod.Get, "jibbr/ping", (request, response) =>
            {
                response.StatusCode = 200;
                response.ContentType = "text/html";
                response.Write("<html>" +
                                   "<head>" +
                                       "<title>JibbR</title>" +
                                   "</head>" +
                                   "<body>" +
                                       "<p>jibbr ping</p>" +
                                   "</body>" +
                               "</html>");

                robot.SendMessage(room, "syn/ack");
            });

            robot.AddRoute(RouteMethod.Post, "jibbr/ping", (request, response) =>
            {
                var body = GetPayload(request);

                var message = string.Format("New push by {0} with {1} commit[s]. {2}",
                                            body["head_commit"]["author"]["username"],
                                            body["commits"].Count(),
                                            body["compare"]);

                response.StatusCode = 200;

                robot.SendMessage(room, message);
            });
        }