Example #1
0
        public WebhookRegistry.HTTPResponseData renderChart(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData();
            if (ChartMemory.HasChartID(arguments[0]))
            {
                hrd.Status            = 200;
                hrd.ReturnContentType = "text/html";
                Chart  C    = ChartMemory.GetChartByID(arguments[0]);
                string page = "<html><head><title>Chart - " + C.ChartName + "</title></head><body bgcolor='black'>";
                // Don't prepend the Table CSS since we need to set colors custom
                page += "<center><a style='color:white'><h2>" + C.ChartDescription + "</h2></a>";
                page += "<table style=\"border:1px inset #00FFFF;border-collapse:separate;border-spacing:0px;padding:6px;\">";
                ChartColumn col = C.ColumnData;
                page += "<thead><th style=\"background:#F0F0F0;border:1px inset #00FFFF;padding:6px\">" + C.ChartName + "</th>";
                foreach (ChartColumnField field in col.Fields)
                {
                    page += "<th style=\"background:" + field.ColorCode + "\";border:1px inset #00FFFF;padding:6px\">" + field.Label + "</th>";
                }
                page += "</thead><tbody>";
                int Pos = 0;
                foreach (ChartRow row in C.RowData)
                {
                    Pos   = 0;
                    page += "<tr><td style=\"border:1px inset #00FFFF;padding:6px;background:#F0F0F0;color:black\">" + row.Label + "</td>";
                    foreach (ChartColumnField field in col.Fields)
                    {
                        // Begin processing row. Keep index of what position we are at
                        int    MaskForPos = col.Pos2Bit(Pos);
                        string ColorCode  = "#000000";
                        if ((row.Mask & MaskForPos) == MaskForPos)
                        {
                            // set the color code to the col code
                            ColorCode = col.Fields[Pos].ColorCode;
                        }
                        page += "<td style=\"border:1px inset #00FFFF;padding:6px;background:" + ColorCode + ";color:white\"> </td>";



                        Pos++;
                    }
                    page += "</tr>";
                }

                page           += "</tbody></table></body>";
                page           += "<script type='text/javascript'>";
                page           += "setInterval(function(){window.location.reload(true);}, 30000);";
                page           += "</script>";
                hrd.ReplyString = page;
            }
            else
            {
                hrd.ReplyString       = "Not found";
                hrd.Status            = 404;
                hrd.ReturnContentType = "text/plain";
            }


            return(hrd);
        }
Example #2
0
 public WebhookRegistry.HTTPResponseData gitHook(List <string> arguments, string body, string method, NameValueCollection headers)
 {
     GitCommands.Process(body, headers.Get("X-Github-Event"));
     WebhookRegistry.HTTPResponseData reply = new WebhookRegistry.HTTPResponseData();
     reply.ReplyString = "Done";
     reply.Status      = 200;
     // removed a line here that triggered a git refresh
     return(reply);
 }
Example #3
0
        public WebhookRegistry.HTTPResponseData List_Logs(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData();
            hrd.Status      = 200;
            hrd.ReplyString = "<center><h2>Group Chat Logs</h2></center>";
            DirectoryInfo di = new DirectoryInfo("BotData/GroupChatLogs");

            foreach (FileInfo fi in di.GetFiles())
            {
                hrd.ReplyString += "<br/><a href='/viewlog/" + Path.GetFileNameWithoutExtension(fi.Name) + "'> " + fi.Name + "</a>";
            }
            hrd.ReturnContentType = "text/html";

            return(hrd);
        }
Example #4
0
        public WebhookRegistry.HTTPResponseData View_Log(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            WebhookRegistry.HTTPResponseData rd = new WebhookRegistry.HTTPResponseData();

            string FinalOutput = "";

            lock (_fileRead)
            {
                try
                {
                    foreach (string s in File.ReadLines("BotData/GroupChatLogs/" + Uri.UnescapeDataString(arguments[0]) + ".log"))
                    {
                        string   tmp  = s;
                        string[] Ltmp = tmp.Split(' ');
                        tmp = "";
                        foreach (string K in Ltmp)
                        {
                            if (K.StartsWith("secondlife://"))
                            {
                                // DO NOT ADD TO OUTPUT
                            }
                            else
                            {
                                tmp += K + " ";
                            }
                        }

                        FinalOutput += tmp + "<br/>";
                    }
                    rd.Status            = 200;
                    rd.ReplyString       = FinalOutput;
                    rd.ReturnContentType = "text/html";
                }
                catch (Exception e)
                {
                    rd.Status      = 418;
                    rd.ReplyString = "You burned... the tea";
                }
            }

            return(rd);
        }
Example #5
0
        public WebhookRegistry.HTTPResponseData listCharts(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData();
            string webpage = "<html><head><title>BotCore5 chart list</title></head><body bgcolor='#000000'>";

            webpage += TABLE_CSS;
            webpage += "\n\n<table class=\"the_table\"><thead><tr><th>Chart Name</th><th>Chart Path</th><th>Description of chart</th></tr></thead><tbody>";

            foreach (Chart c in ChartMemory.Instance.Charts)
            {
                webpage += "\n<tr><td>" + c.ChartName;
                webpage += "</td><td><a href='/charts/" + c.ChartID + "'>" + c.ChartName + "</a></td><td>" + c.ChartDescription + "</td></tr>";
            }
            webpage += "</tbody>";
            webpage += "</table></body></html>";

            hrd.ReplyString       = webpage;
            hrd.ReturnContentType = "text/html";
            hrd.Status            = 200;


            return(hrd);
        }
Example #6
0
        public WebhookRegistry.HTTPResponseData ejectnotif(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            string[] splitter = body.Split(new[] { '[', ']' });
            string   req      = "[" + splitter[1] + "]" + splitter[2];

            splitter = req.Split(new[] { ' ' });

            string KickName = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(splitter[1] + " " + splitter[2]));
            string Kicked   = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(splitter[3] + " " + splitter[4]));

            req = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(req));

            string concat = Kicked + "|" + req + "|" + KickName;

            splitter = concat.Split(new[] { '|' });

            CommandRegistry.Instance.RunCommand("auto_buildnotice " + Kicked + " " + req + " " + KickName, BotSession.Instance.grid.Self.AgentID, 1000, Destinations.DEST_GROUP, BotSession.Instance.grid.Self.AgentID, BotSession.Instance.ConfigurationHandle.first + " " + BotSession.Instance.ConfigurationHandle.last);


            WebhookRegistry.HTTPResponseData reply = new WebhookRegistry.HTTPResponseData();
            reply.Status      = 200;
            reply.ReplyString = "Done";
            return(reply);
        }
Example #7
0
        public WebhookRegistry.HTTPResponseData showHelp(List <string> arguments, string body, string method, NameValueCollection headers)
        {
            WebhookRegistry.HTTPResponseData httpReply = new WebhookRegistry.HTTPResponseData();
            CommandRegistry reg = CommandRegistry.Instance;

            string Final = "<body bgcolor='black'><style type='text/css'>table.HelpTable {  border: 5px solid #1C6EA4;" +
                           "  background - color: #000000; " +
                           "  width: 100 %;            text - align: left;            border - collapse: collapse;" +
                           "        }        table.HelpTable td, table.HelpTable th        {            border: 3px solid #AAAAAA;" +
                           "  padding: 3px 2px;        }        table.HelpTable tbody td {  font-size: 19px;  color: #69FAF7;" +
                           "}    table.HelpTable tr:nth-child(even)    {    background: #000000;}    table.HelpTable thead" +
                           "    {        background: #26A486;  background: -moz-linear-gradient(top, #5cbba4 0%, #3bad92 66%, #26A486 100%);" +
                           "  background: -webkit-linear-gradient(top, #5cbba4 0%, #3bad92 66%, #26A486 100%);" +
                           "  background: linear-gradient(to bottom, #5cbba4 0%, #3bad92 66%, #26A486 100%);" +
                           "  border-bottom: 2px solid #444444;}    table.HelpTable thead th {  font-size: 25px;" +
                           "  font-weight: bold;  color: #FFFFFF;  text-align: center;  border-left: 2px solid #D0E4F5;" +
                           "}table.HelpTable thead th:first-child {  border-left: none;}table.HelpTable tfoot td {  font-size: 14px;" +
                           "}table.HelpTable tfoot.links{    text-align: right;}table.HelpTable tfoot.links a{display: inline - block;" +
                           "background: #1C6EA4;  color: #FFFFFF;  padding: 2px 8px;    border - radius: 5px;}</style>";

            Final += "<table class='HelpTable'><thead><tr><th>Bot Version</th><th>" + ASMInfo.BotVer + "</th></tr></table><br/>";

            Final += "<table class='HelpTable'><thead><tr><th>Command</th><th>Minimum Level Required</th><th>Usage</th><th>Allowed Sources</th></thead><tbody>";
            foreach (KeyValuePair <string, CommandGroup> cmd in reg.Cmds)
            {
                // Command
                Final += "<tr><td>" + cmd.Value.Command + "</td>";
                // Level
                Final += "<td>" + cmd.Value.minLevel.ToString() + "</td>";
                // Usage
                Final += "<td>" + cmd.Value.cmdUsage.RawUsage() + "</td>";
                // Allowed Sources
                Final += "<td>" + cmd.Value.CommandSource + "</td>";
            }
            Final += "</tbody></table>";

            Final += "<table class='HelpTable'><thead><tr><th>Hook Path</th><tr></thead><tbody>";
            WebhookRegistry regx = WebhookRegistry.Instance;

            foreach (KeyValuePair <string, WebhookAttribs> hooks in regx.hooks)
            {
                Final += "<tr><td>" + hooks.Value.Path + "</td></tr>";
            }
            Final += "</tbody></table>";

            Final += "<br/><table class='HelpTable'><thead><tr><th>Assembly</th><th>Version</th><th># Of Commands</th><th>Total Classes</th></tr></thead><tbody>";

            foreach (Assembly A in AppDomain.CurrentDomain.GetAssemblies())
            {
                Final += "<tr><td>" + A.GetName().Name + "</td><td>" + A.GetName().Version + "</td>";
                int TotalCommandsContained = 0;
                int TotalClasses           = 0;
                foreach (Type T in A.GetTypes())
                {
                    if (T.IsClass)
                    {
                        TotalClasses++;
                        foreach (MethodInfo MI in T.GetMethods())
                        {
                            CommandGroup[] CG = (CommandGroup[])MI.GetCustomAttributes(typeof(CommandGroup), false);
                            TotalCommandsContained += CG.Length;
                        }
                    }
                }

                Final += "<td>" + TotalCommandsContained.ToString() + "</td><td>" + TotalClasses.ToString() + "</td></tr>";
            }
            Final += "</tbody></table>";


            httpReply.ReplyString       = Final;
            httpReply.Status            = 200;
            httpReply.ReturnContentType = "text/html";

            return(httpReply);
        }