Example #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());
        }
Example #2
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());
        }
Example #3
0
        XMLPersistenceDictionary readOnymityXML()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.CheckFileExists = true;
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                OnymityDatasaving.OnymityDatasaving onymityxml = new OnymityDatasaving.OnymityDatasaving();
                try
                {
                    onymityxml.load(ofd.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to read the XML!\n" + ex.Message);
                    cedlibxml = null;
                    return null;
                }

                XMLPersistenceDictionary dict = new XMLPersistenceDictionary("cedlibxml.xml", false);
                foreach (var item in onymityxml.xmldict.innerdict)
                {
                    savenode cursnode = new savenode(item.name, item.obj);
                    cedlibxml.Add(cursnode);
                    fillCedLibXMLTree(cursnode, item);
                }
                onymityxml = null;
                return dict;
            }
            else return null;
        }
Example #4
0
 void Mergedicts(XMLPersistenceDictionary foreigndict, XMLPersistenceDictionary curdict)
 {
     foreach (var item in foreigndict)
     {
         curdict.Add(item);
         Mergedicts(item.childnodes, curdict[item.name].childnodes);
     }
 }