Exemplo n.º 1
0
        public string addurl(BotFunctionData BotInput)
        {
            StringBuilder responsebuilder = new StringBuilder();

            if (BotInput.input.Split(' ').Length < 2)
            {
                return("You have to provide an url, silly.");
            }
            if (!persistence.ContainsKey("urls"))
            {
                persistence.Add(new savenode("urls", "urls!"));
            }
            System.Uri url;
            if (System.Uri.TryCreate(BotInput.input.Split(' ')[1], UriKind.Absolute, out url))
            {
                if (!persistence["urls"].childnodes.ContainsValue(BotInput.input.Split(' ')[1]))
                {
                    System.Net.WebClient x = new System.Net.WebClient();
                    string source          = x.DownloadString(url);
                    string title           = System.Text.RegularExpressions.Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Groups["Title"].Value;
                    persistence["urls"].childnodes.Add(new savenode(title, url.ToString()));
                    responsebuilder.Append("Added!");
                }
                else
                {
                    responsebuilder.Append("That was already in the list!");
                }
            }
            else
            {
                responsebuilder.Append("That's not a valid url, silly.");
            }
            return(responsebuilder.ToString());
        }
Exemplo n.º 2
0
            public string changexml(BotFunctionData BotInput)
            {
                //command format: changexml add|del|delchild|change %dictitem% %itemtoadd|del|change% %change|addargument%
                StringBuilder responsebuilder = new StringBuilder();

                string[] splittedinput = BotInput.input.Split(' ');
                if (splittedinput.Length < 3)
                {
                    return("You didn't specify enough parameters");
                }
                if (!persistence.ContainsKey(splittedinput[2]))
                {
                    return("Specified item wasn't found in the xml file");
                }
                switch (splittedinput[1])
                {
                case "add":
                    if (splittedinput.Length < 5)
                    {
                        return("You didn't specify enough parameters for this command.");
                    }
                    persistence[splittedinput[2]].childnodes.Add(new  savenode(splittedinput[3], splittedinput[4]));
                    responsebuilder.AppendFormat("Succesfully added {0}({1}) to {2}", splittedinput[3], splittedinput[4], splittedinput[2]);
                    break;

                case "delchild":
                    if (splittedinput.Length < 4)
                    {
                        return("You didn't specify enough parameters for this command.");
                    }
                    persistence[splittedinput[2]].childnodes.Remove(persistence[splittedinput[2]].childnodes[splittedinput[3]]);
                    responsebuilder.AppendFormat("Succesfully removed {0}({1}) from {2}", splittedinput[3], splittedinput[4], splittedinput[2]);
                    break;

                case "del":
                    persistence.Remove(splittedinput[2]);
                    responsebuilder.AppendFormat("Succesfully removed {0}", splittedinput[2]);
                    break;

                case "change":
                    if (splittedinput.Length < 5)
                    {
                        return("You didn't specify enough parameters for this command.");
                    }
                    try
                    {
                        return("Command not supported yet..");
                    }
                    catch (Exception ex)
                    {
                        logger.logerror(ex); return(ex.Message);
                    }
                    break;

                default:
                    return("Command not recognized. Try manual for help on using changexml");
                }
                return(responsebuilder.ToString());
            }
Exemplo n.º 3
0
        public string slap(SteamStuff.BotFunctionData BotInput)
        {
            if (BotInput.Ctype == SteamStuff.ChatType.PM)
            {
                return("This command is only supported in group chats.");
            }
            StringBuilder responsebuilder = new StringBuilder();

            if (BotInput.input.Split(' ').Length < 2)
            {
                return("How about I slap YO shit");
            }
            if (BotInput.input.Split(' ')[1].ToLower() != "ced")
            {
                responsebuilder.Append("*slaps " + BotInput.input.Split(' ')[1] + "*");
                if (!persistence.ContainsKey("slapcount"))
                {
                    persistence.Add("slapcount", "Foxy fluffs are everything.");
                }
                if (persistence["slapcount"].childnodes.ContainsKey(BotInput.input.Split(' ')[1].ToLower()))
                {
                    string xmlvalue = ((string)persistence["slapcount"].childnodes[BotInput.input.Split(' ')[1].ToLower()].obj);
                    xmlvalue = (Convert.ToInt64(xmlvalue) + 1).ToString();
                    persistence["slapcount"].childnodes[BotInput.input.Split(' ')[1].ToLower()].obj = xmlvalue;
                }
                else
                {
                    persistence["slapcount"].childnodes.Add(new savenode(BotInput.input.Split(' ')[1].ToLower(), "1"));
                }
            }
            else
            {
                responsebuilder.Append("I will not hurt Ced :c");
            }

            return(responsebuilder.ToString());
        }