/// <summary>Finds all internal wikilinks in page text, excluding interwiki /// links, links to sister projects, categories, embedded images and links in /// image descriptions.</summary> /// <returns>Returns the PageList object, where page titles are the wikilinks, /// found in text.</returns> public PageList GetLinks() { MatchCollection matches = site.wikiLinkRE.Matches(text); StringCollection exclLinks = new StringCollection(); exclLinks.AddRange(GetInterWikiLinks()); exclLinks.AddRange(GetSisterWikiLinks(true)); StringCollection inclLinks = new StringCollection(); string str; for(int i = 0; i < matches.Count; i++) if (exclLinks.Contains(matches[i].Groups[1].Value) == false && exclLinks.Contains(matches[i].Groups[1].Value.TrimStart(':')) == false) { str = matches[i].Groups[1].Value; if (str.IndexOf("#") != -1) str = str.Substring(0, str.IndexOf("#")); inclLinks.Add(str); } PageList pl = new PageList(site, inclLinks); pl.RemoveNamespaces(new int[] {6,14}); foreach (Page p in pl.pages) p.title = p.title.TrimStart(':'); return pl; }
/// <summary>Gets page titles for this PageList from specified wiki category page, excluding /// subcategories. Use FillSubsFromCategory function to get subcategories.</summary> /// <param name="categoryName">Category name, with or without prefix.</param> public void FillFromCategory(string categoryName) { int count = pages.Count; PageList pl = new PageList(site); pl.FillAllFromCategory(categoryName); pl.RemoveNamespaces(new int[] {14}); pages.AddRange(pl.pages); if (pages.Count != count) Bot.LogEvent( Bot.Msg("PageList filled with {0} page titles, found in \"{1}\" category."), (pages.Count - count).ToString(), categoryName); else Console.Error.WriteLine( Bot.Msg("Nothing was found in \"{0}\" category."), categoryName); }