Пример #1
0
        private static string GetPopularRoutes(Area area, ResultParameters parameters)
        {
            string result = "";

            List <Route> popularRoutes = new List <Route>();

            if (area.PopularRouteIDs.Count == 0) //MountainProject doesn't list any popular routes. Figure out some ourselves
            {
                popularRoutes = area.GetPopularRoutes(3);
            }
            else
            {
                area.PopularRouteIDs.ForEach(id => popularRoutes.Add(MountainProjectDataSearch.GetItemWithMatchingID(id, MountainProjectDataSearch.DestAreas) as Route));
            }

            foreach (Route popularRoute in popularRoutes)
            {
                result += $"\n- {Markdown.Link(popularRoute.Name, popularRoute.URL)} {GetRouteAdditionalInfo(popularRoute, parameters)}";
            }

            if (string.IsNullOrEmpty(result))
            {
                return("");
            }

            return("Popular routes:" + Markdown.NewLine + result + Markdown.NewLine);
        }
Пример #2
0
        public static string GetLocationString(MPObject child, Area referenceLocation = null)
        {
            MPObject innerParent = MountainProjectDataSearch.GetInnerParent(child);
            MPObject outerParent = MountainProjectDataSearch.GetOuterParent(child);

            if (referenceLocation != null) //Override the "innerParent" in situations where we want the location string to include the "insisted" location
            {
                //Only override if the location is not already present
                if (innerParent?.URL != referenceLocation.URL &&
                    outerParent?.URL != referenceLocation.URL)
                {
                    innerParent = referenceLocation;
                }
            }

            if (innerParent == null)
            {
                return("");
            }

            string locationString = $"Located in {Markdown.Link(innerParent.Name, innerParent.URL)}";

            if (outerParent != null && outerParent.URL != innerParent.URL)
            {
                locationString += $", {Markdown.Link(outerParent.Name, outerParent.URL)}";
            }

            locationString += Markdown.NewLine;

            return(locationString);
        }
Пример #3
0
        private static string GetPopularRoutes(Area area, ResultParameters parameters)
        {
            string result = "Popular routes:\n";

            List <Route> popularRoutes = new List <Route>();

            if (area.PopularRouteUrls.Count == 0) //MountainProject doesn't list any popular routes. Figure out some ourselves
            {
                popularRoutes = area.GetPopularRoutes(3);
            }
            else
            {
                List <MPObject> itemsToSearch = new List <MPObject>();
                itemsToSearch.AddRange(area.SubAreas);
                itemsToSearch.AddRange(area.Routes);

                area.PopularRouteUrls.ForEach(p => popularRoutes.Add(MountainProjectDataSearch.GetItemWithMatchingUrl(p, itemsToSearch) as Route));
            }

            foreach (Route popularRoute in popularRoutes)
            {
                result += $"\n- {Markdown.Link(popularRoute.Name, popularRoute.URL)} {GetRouteAdditionalInfo(popularRoute, parameters)}";
            }

            if (string.IsNullOrEmpty(result))
            {
                return("");
            }

            result += Markdown.NewLine;

            return(result);
        }
Пример #4
0
        public static string GetBotLinks(VotableThing relatedThing = null)
        {
            List <string> botLinks = new List <string>();

            if (relatedThing != null)
            {
                string encodedLink = WebUtility.HtmlEncode(RedditHelper.GetFullLink(relatedThing.Permalink));
                botLinks.Add(Markdown.Link("Feedback", "https://docs.google.com/forms/d/e/1FAIpQLSchgbXwXMylhtbA8kXFycZenSKpCMZjmYWMZcqREl_OlCm4Ew/viewform?usp=pp_url&entry.266808192=" + encodedLink));
            }
            else
            {
                botLinks.Add(Markdown.Link("Feedback", "https://docs.google.com/forms/d/e/1FAIpQLSchgbXwXMylhtbA8kXFycZenSKpCMZjmYWMZcqREl_OlCm4Ew/viewform?usp=pp_url"));
            }

            botLinks.Add(Markdown.Link("FAQ", "https://github.com/derekantrican/MountainProject/wiki/Bot-FAQ"));
            botLinks.Add(Markdown.Link("Syntax", "https://github.com/derekantrican/MountainProject/wiki/Bot-Syntax"));
            botLinks.Add(Markdown.Link("GitHub", "https://github.com/derekantrican/MountainProject"));
            botLinks.Add(Markdown.Link("Donate", "https://www.paypal.me/derekantrican"));

            return(string.Join(" | ", botLinks));
        }
Пример #5
0
        private static string GetBotLinks(Comment relatedComment = null)
        {
            List <string> botLinks = new List <string>();

            if (relatedComment != null)
            {
                string commentLink = WebUtility.HtmlEncode(RedditHelper.GetFullLink(relatedComment.Permalink));
                botLinks.Add(Markdown.Link("Feedback", "https://docs.google.com/forms/d/e/1FAIpQLSchgbXwXMylhtbA8kXFycZenSKpCMZjmYWMZcqREl_OlCm4Ew/viewform?usp=pp_url&entry.266808192=" + commentLink));
            }
            else
            {
                botLinks.Add(Markdown.Link("Feedback", "https://docs.google.com/forms/d/e/1FAIpQLSchgbXwXMylhtbA8kXFycZenSKpCMZjmYWMZcqREl_OlCm4Ew/viewform?usp=pp_url"));
            }

            botLinks.Add(Markdown.Link("FAQ", "https://github.com/derekantrican/MountainProject/wiki/Bot-FAQ"));
            botLinks.Add(Markdown.Link("Syntax", "https://github.com/derekantrican/MountainProject/wiki/Bot-Syntax"));
            botLinks.Add(Markdown.Link("Grade Conversion", "https://www.mountainproject.com/international-climbing-grades"));
            botLinks.Add(Markdown.Link("GitHub", "https://github.com/derekantrican/MountainProject"));
            botLinks.Add(Markdown.Link("Donate", "https://www.paypal.me/derekantrican"));

            return(string.Join(" | ", botLinks));
        }
Пример #6
0
        public static string GetLocationString(MPObject child, Area referenceLocation = null)
        {
            MPObject innerParent, outerParent;

            innerParent = null;
            outerParent = MountainProjectDataSearch.GetParent(child, 1); //Get state that route/area is in
            if (child is Route)
            {
                innerParent = MountainProjectDataSearch.GetParent(child, -2); //Get the "second to last" parent https://github.com/derekantrican/MountainProject/issues/12

                if (innerParent.URL == outerParent.URL)
                {
                    innerParent = MountainProjectDataSearch.GetParent(child, -1);
                }
            }
            else if (child is Area)
            {
                innerParent = MountainProjectDataSearch.GetParent(child, -1); //Get immediate parent
            }
            if (innerParent == null ||                                        //If "child" is a dest area, the parent will be "All Locations" which won't be in our directory
                innerParent.URL == Utilities.INTERNATIONALURL)                //If "child" is an area like "Europe"
            {
                return("");
            }

            if (outerParent.URL == Utilities.INTERNATIONALURL) //If this is international, get the country instead of the state (eg "China")
            {
                if (child.ParentUrls.Count > 3)
                {
                    if (child.ParentUrls.Contains(Utilities.AUSTRALIAURL)) //Australia is both a continent and a country so it is an exception
                    {
                        outerParent = MountainProjectDataSearch.GetParent(child, 2);
                    }
                    else
                    {
                        outerParent = MountainProjectDataSearch.GetParent(child, 3);
                    }
                }
                else
                {
                    return(""); //Return a blank string if we are in an area like "China" (so we don't return a string like "China is located in Asia")
                }
            }

            if (referenceLocation != null) //Override the "innerParent" in situations where we want the location string to include the "insisted" location
            {
                //Only override if the location is not already present
                if (innerParent.URL != referenceLocation.URL &&
                    outerParent.URL != referenceLocation.URL)
                {
                    innerParent = referenceLocation;
                }
            }

            string locationString = $"Located in {Markdown.Link(innerParent.Name, innerParent.URL)}";

            if (outerParent != null && outerParent.URL != innerParent.URL)
            {
                locationString += $", {Markdown.Link(outerParent.Name, outerParent.URL)}";
            }

            locationString += Markdown.NewLine;

            return(locationString);
        }