public IProcessingResult LastPostedImageID(IBot bot, IProcessingResult pr, IChatMessage msg, string arg)
    {
        pr.Solved         = true;
        pr.Respond        = true;
        pr.ResponseOrigin = Helper.GetExecutingMethodName(this);

        var v = bot.GetModuleByName("Potato");

        if (v != null)
        {
            var last = (string)v.GetParameter("last posted image url");

            string gris      = @"https://www.google.com/searchbyimage?image_url=";
            string snao      = @"http://saucenao.com/search.php?url=";
            string iqdb      = @"http://iqdb.org/?url=";
            string tin       = @"http://tineye.com/search?url=";
            string imagelink = last;
            string grislink  = gris + imagelink;
            string snaolink  = snao + imagelink;
            string iqdblink  = iqdb + imagelink;
            string tinlink   = tin + imagelink;

            string niceresponse  = "[Google Reverse Image Search](" + grislink + "), [TinEye](" + tinlink + "), [SauceNAO](" + snaolink + "), [iqdb](" + iqdblink + ").";
            string shortresponse = grislink + " | " + tinlink + " | " + snaolink + " | " + iqdblink;

            pr.ResponseText = niceresponse.Length < 500 ? niceresponse : shortresponse;
        }

        return(pr);
    }
    public IProcessingResult LastPostedImageID(IBot bot, IProcessingResult pr, IChatMessage msg, string arg)
    {
        pr.Solved = true;
        pr.Respond = true;
        pr.ResponseOrigin = Helper.GetExecutingMethodName(this);

        var v = bot.GetModuleByName("Potato");

        if (v != null)
        {
            var last = (string)v.GetParameter("last posted image url");

            string gris = @"https://www.google.com/searchbyimage?image_url=";
            string snao = @"http://saucenao.com/search.php?url=";
            string iqdb = @"http://iqdb.org/?url=";
            string tin = @"http://tineye.com/search?url=";
            string imagelink = last;
            string grislink = gris + imagelink;
            string snaolink = snao + imagelink;
            string iqdblink = iqdb + imagelink;
            string tinlink = tin + imagelink;

            string niceresponse = "[Google Reverse Image Search](" + grislink + "), [TinEye](" + tinlink + "), [SauceNAO](" + snaolink + "), [iqdb](" + iqdblink + ").";
            string shortresponse = grislink + " | " + tinlink + " | " + snaolink + " | " + iqdblink;

            pr.ResponseText = niceresponse.Length < 500 ? niceresponse : shortresponse;
        }

        return pr;
    }
    public IProcessingResult Status(IBot bot, IProcessingResult pr)
    {
        pr.Solved = true;
        pr.Respond = true;
        pr.ResponseOrigin = Helper.GetExecutingMethodName(this);
        //pr.ResponseContent = "status message";
        //ResponseText = "Uptime: " + Helper.GetUptime(Bot.initTime) + ". Firefox memory use: " 
        var uptime = DateTime.UtcNow - bot.StartTimeUTC;
        var memusage = Helper.GetBotAppMemoryUsage();



        var logDir = bot.LogDirectoryPath;

        var logDirInfo = new DirectoryInfo(logDir);

        var logFileInfos = logDirInfo.GetFiles("*.log", SearchOption.AllDirectories);
        var logZipInfo = logDirInfo.GetFiles("*.zip", SearchOption.AllDirectories);

        long logFileSize = 0;
        foreach (var info in logFileInfos)
            logFileSize += info.Length;

        long logZipSize = 0;
        foreach (var info in logZipInfo)
            logZipSize += info.Length;

        var logText = logFileInfos.Length + " log files, size: " + logFileSize + "; " +
                              logZipInfo.Length + " archives, size: " + logZipSize + ".";


        var potatoDir = bot.GetModuleByName("Potato").ModuleDir;
        var potDirInfo = new DirectoryInfo(potatoDir);

        var potFileInfos = potDirInfo.GetFiles("*.txt", SearchOption.AllDirectories);
        var potZipInfo = potDirInfo.GetFiles("*.zip", SearchOption.AllDirectories);

        long potSize = 0;
        long potZipSize = 0;

        foreach (var info in potFileInfos)
            potSize += info.Length;

        foreach (var info in potZipInfo)
            potZipSize += info.Length;

        var potText = potFileInfos.Length + " list files, size: " + potSize + "; " +
                              potZipInfo.Length + " archives, size: " + potZipSize + ".";


        pr.ResponseText = "Bot app memory use: " + memusage + " bytes." +
            " Uptime: " + uptime + "." +
            " " + logText +
            " " + potText;

        return pr;
    }
Beispiel #4
0
        private IProcessingResult InvokeImplicitCommand(IBot bot, IProcessingResult pr, IChatMessage msg, string cmd, string arg)
        {
            var txt = Helper.RemoveBotNamesAndTriggerSymbol(bot.Name, msg.Text, bot.TriggerSymbol);
            var low = txt.ToLowerInvariant();


            // get uploader name and image tag
            {
                if (low == "uploader" ||
                    low == "info" ||
                    low == "tag")
                {
                    var v = bot.GetModuleByName("Potato");
                    if (v != null)
                    {
                        var resp = (string)v.GetParameter("last posted image short info");
                        pr.ResponseText = resp;
                        pr.Solved       = true;
                        pr.Respond      = true;

                        return(pr);
                    }
                }
            }


            // who − last image identification
            {
                var words = low.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                if (words.Contains("who") ||
                    words.Contains("who's") ||
                    words.Contains("what") ||
                    words.Contains("wut") ||
                    words.Contains("wat") ||
                    words.Contains("where") && words.Contains("from"))
                {
                    var v = bot.GetModuleByName("CoreCommands");

                    if (v != null)
                    {
                        pr = v.Command(bot, pr, msg, "last", arg, cmd, arg);

                        pr.Solved  = true;
                        pr.Respond = true;

                        return(pr);
                    }
                }
            }


            // loli − lolis are the best…
            {
                if (low.Contains("loli"))
                {
                    var v = bot.GetModuleByName("CoreCommands");

                    if (v != null)
                    {
                        pr = v.Command(bot, pr, msg, "say", "Lolis are the best!", cmd, arg);

                        pr.Solved  = true;
                        pr.Respond = true;

                        return(pr);
                    }
                }
            }


            return(pr);
        }
Beispiel #5
0
        private IProcessingResult InvokeImplicitCommand(IBot bot, IProcessingResult pr, IChatMessage msg, string cmd, string arg)
        {
            var txt = Helper.RemoveBotNamesAndTriggerSymbol(bot.Name, msg.Text, bot.TriggerSymbol);
            var low = txt.ToLowerInvariant();

            // get uploader name and image tag
            {
                if (low == "uploader" ||
                    low == "info" ||
                    low == "tag")
                {
                    var v = bot.GetModuleByName("Potato");
                    if (v != null)
                    {
                        var resp = (string)v.GetParameter("last posted image short info");
                        pr.ResponseText = resp;
                        pr.Solved = true;
                        pr.Respond = true;

                        return pr;
                    }
                }
            }

            // who − last image identification
            {
                var words = low.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                if (words.Contains("who") ||
                    words.Contains("who's") ||
                    words.Contains("what") ||
                    words.Contains("wut") ||
                    words.Contains("wat") ||
                    words.Contains("where") && words.Contains("from"))
                {
                    var v = bot.GetModuleByName("CoreCommands");

                    if (v != null)
                    {
                        pr = v.Command(bot, pr, msg, "last", arg, cmd, arg);

                        pr.Solved = true;
                        pr.Respond = true;

                        return pr;
                    }
                }
            }

            // loli − lolis are the best…
            {
                if (low.Contains("loli"))
                {
                    var v = bot.GetModuleByName("CoreCommands");

                    if (v != null)
                    {
                        pr = v.Command(bot, pr, msg, "say", "Lolis are the best!", cmd, arg);

                        pr.Solved = true;
                        pr.Respond = true;

                        return pr;
                    }
                }
            }

            return pr;
        }
    public IProcessingResult Status(IBot bot, IProcessingResult pr)
    {
        pr.Solved         = true;
        pr.Respond        = true;
        pr.ResponseOrigin = Helper.GetExecutingMethodName(this);
        //pr.ResponseContent = "status message";
        //ResponseText = "Uptime: " + Helper.GetUptime(Bot.initTime) + ". Firefox memory use: "
        var uptime   = DateTime.UtcNow - bot.StartTimeUTC;
        var memusage = Helper.GetBotAppMemoryUsage();



        var logDir = bot.LogDirectoryPath;

        var logDirInfo = new DirectoryInfo(logDir);

        var logFileInfos = logDirInfo.GetFiles("*.log", SearchOption.AllDirectories);
        var logZipInfo   = logDirInfo.GetFiles("*.zip", SearchOption.AllDirectories);

        long logFileSize = 0;

        foreach (var info in logFileInfos)
        {
            logFileSize += info.Length;
        }

        long logZipSize = 0;

        foreach (var info in logZipInfo)
        {
            logZipSize += info.Length;
        }

        var logText = logFileInfos.Length + " log files, size: " + logFileSize + "; " +
                      logZipInfo.Length + " archives, size: " + logZipSize + ".";


        var potatoDir  = bot.GetModuleByName("Potato").ModuleDir;
        var potDirInfo = new DirectoryInfo(potatoDir);

        var potFileInfos = potDirInfo.GetFiles("*.txt", SearchOption.AllDirectories);
        var potZipInfo   = potDirInfo.GetFiles("*.zip", SearchOption.AllDirectories);

        long potSize    = 0;
        long potZipSize = 0;

        foreach (var info in potFileInfos)
        {
            potSize += info.Length;
        }

        foreach (var info in potZipInfo)
        {
            potZipSize += info.Length;
        }

        var potText = potFileInfos.Length + " list files, size: " + potSize + "; " +
                      potZipInfo.Length + " archives, size: " + potZipSize + ".";


        pr.ResponseText = "Bot app memory use: " + memusage + " bytes." +
                          " Uptime: " + uptime + "." +
                          " " + logText +
                          " " + potText;

        return(pr);
    }