Example #1
0
        /// <summary>
        /// This will modify the passed auction and fill in any guessable things such as item name (from tag)
        /// </summary>
        /// <param name="auction"></param>
        /// <returns>The modified original auction</returns>
        public PlayerAuctionsCommand.AuctionResult GuessMissingProperties(PlayerAuctionsCommand.AuctionResult auction)
        {
            if (String.IsNullOrEmpty(auction.ItemName))
            {
                auction.ItemName = ItemDetails.TagToName(auction.Tag);
            }
            if (auction.StartingBid == 0 && auction.Bin)
            {
                auction.StartingBid = auction.HighestBid;
            }

            return(auction);
        }
Example #2
0
 private static async Task PrintItems(RequestContext reqcon)
 {
     using (var context = new HypixelContext())
     {
         var data = await context.Items.Select(p => new { p.Tag }).Take(10000).ToListAsync();
         StringBuilder builder = GetSiteBuilder("Item");
         foreach (var item in data)
         {
             var name = ItemDetails.TagToName(item.Tag);
             builder.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", $"/item/{item.Tag}/{name}", $"{name} auctions");
         }
         await reqcon.WriteAsync(builder.ToString());
     }
 }
Example #3
0
        internal void AddPopularSite(string type, string id)
        {
            string title = "";

            if (type == "player")
            {
                title = PlayerSearch.Instance.GetNameWithCache(id) + " auctions hypixel skyblock";
            }
            else if (type == "item")
            {
                title = ItemDetails.TagToName(id) + " price hypixel skyblock";
            }
            var entry = new PopularSite(title, $"{type}/{id}");

            if (!popularSite.Contains(entry))
            {
                popularSite.Enqueue(entry);
            }
            if (popularSite.Count > 100)
            {
                popularSite.TryDequeue(out PopularSite result);
            }
        }
Example #4
0
        internal void PriceAlert(SubscribeItem sub, string productId, double value)
        {
            var text = $"{ItemDetails.TagToName(productId)} reached {value.ToString("0.00")}";

            Task.Run(() => Send(sub.UserId, $"Price Alert", text, $"{BaseUrl}/item/{productId}", ItemIconUrl(productId))).ConfigureAwait(false);
        }
Example #5
0
 static ItemDetails()
 {
     Instance = new ItemDetails();
     Instance.Load();
 }
Example #6
0
        public static async Task <string> ModifyContent(string path, byte[] contents, Server.RequestContext res)
        {
            string parameter = "";
            var    urlParts  = path.Split('/', '?', '#');

            if (urlParts.Length > 2)
            {
                parameter = urlParts[2];
            }
            string description     = "Browse over 200 million auctions, and the bazaar of Hypixel SkyBlock.";
            string longDescription = null;
            string title           = defaultTitle;
            string imageUrl        = "https://sky.coflnet.com/logo192.png";
            string keyword         = "";

            var    start       = Encoding.UTF8.GetString(contents).Split("<title>");
            var    headerStart = start[0] + "<title>";
            var    parts       = start[1].Split("</head>");
            string header      = parts.First();
            string html        = parts.Last().Substring(0, parts.Last().Length - 14);


            if (path.StartsWith("/p/"))
            {
                return(res.RedirectSkyblock(parameter, "player"));
            }
            if (path.StartsWith("/a/"))
            {
                return(res.RedirectSkyblock(parameter, "auction"));
            }
            if (path == "/item/" || path == "/item")
            {
                return(res.RedirectSkyblock());
            }

            // try to fill in title
            if (path.Contains("auction/"))
            {
                await WriteStart(res, headerStart);

                // is an auction
                using (var context = new HypixelContext())
                {
                    var result = context.Auctions.Where(a => a.Uuid == parameter)
                                 .Select(a => new { a.Tag, a.AuctioneerId, a.ItemName, a.End, bidCount = a.Bids.Count, a.Tier, a.Category }).FirstOrDefault();
                    if (result == null)
                    {
                        await WriteHeader("/error", res, "This site was not found", "Error", imageUrl, null, header);

                        await res.WriteEnd(html);

                        return("");
                    }


                    var playerName = PlayerSearch.Instance.GetNameWithCache(result.AuctioneerId);
                    title       = $"Auction for {result.ItemName} by {playerName}";
                    description = $"{title} ended on {result.End.ToString("yyyy-MM-dd HH\\:mm\\:ss")} with {result.bidCount} bids, Category: {result.Category}, {result.Tier}.";


                    if (!string.IsNullOrEmpty(result.Tag))
                    {
                        imageUrl = "https://sky.lea.moe/item/" + result.Tag;
                    }
                    else
                    {
                        imageUrl = SearchService.PlayerHeadUrl(result.AuctioneerId);
                    }

                    await WriteHeader(path, res, description, title, imageUrl, keyword, header);

                    longDescription = description
                                      + $"<ul><li> <a href=\"/player/{result.AuctioneerId}/{playerName}\"> other auctions by {playerName} </a></li>"
                                      + $" <li><a href=\"/item/{result.Tag}/{result.ItemName}\"> more auctions for {result.ItemName} </a></li></ul>";
                    keyword = $"{result.ItemName},{playerName}";
                }
            }
            else if (path.Contains("player/"))
            {
                if (parameter.Length < 30)
                {
                    var uuid = PlayerSearch.Instance.GetIdForName(parameter);
                    return(res.RedirectSkyblock(uuid, "player", uuid));
                }

                await WriteStart(res, headerStart);

                keyword     = PlayerSearch.Instance.GetNameWithCache(parameter);
                title       = $"{keyword} Auctions and bids";
                description = $"Auctions and bids for {keyword} in hypixel skyblock.";

                imageUrl = SearchService.PlayerHeadUrl(parameter);

                await WriteHeader(path, res, description, title, imageUrl, keyword, header);


                var auctions = GetAuctions(parameter, keyword);
                var bids     = GetBids(parameter, keyword);
                await res.WriteAsync(html);

                await res.WriteAsync(DETAILS_START + $"<h1>{title}</h1>{description} " + await auctions);

                await res.WriteEnd(await bids + PopularPages());

                return("");
            }
            else if (path.Contains("item/") || path.Contains("i/"))
            {
                if (path.Contains("i/"))
                {
                    return(res.RedirectSkyblock(parameter, "item", keyword));
                }
                if (!ItemDetails.Instance.TagLookup.ContainsKey(parameter))
                {
                    var upperCased = parameter.ToUpper();
                    if (ItemDetails.Instance.TagLookup.ContainsKey(upperCased))
                    {
                        return(res.RedirectSkyblock(upperCased, "item"));
                    }
                    // likely not a tag
                    parameter = HttpUtility.UrlDecode(parameter);
                    var thread = ItemDetails.Instance.Search(parameter, 1);
                    thread.Wait();
                    var item = thread.Result.FirstOrDefault();
                    keyword   = item?.Name;
                    parameter = item?.Tag;
                    return(res.RedirectSkyblock(parameter, "item", keyword));
                }
                await WriteStart(res, headerStart);

                keyword = ItemDetails.TagToName(parameter);


                var i = await ItemDetails.Instance.GetDetailsWithCache(parameter);

                path = CreateCanoicalPath(urlParts, i);
                var name = i?.Names?.FirstOrDefault();
                if (name != null)
                {
                    keyword = name;
                }

                title = $"{keyword} price ";
                float price = await GetAvgPrice(parameter);

                description = $"Price for item {keyword} in hypixel SkyBlock is {price.ToString("0,0.0")} on average. Visit for a nice chart and filter options";
                imageUrl    = "https://sky.lea.moe/item/" + parameter;
                if (parameter.StartsWith("PET_") && !parameter.StartsWith("PET_ITEM") || parameter.StartsWith("POTION"))
                {
                    imageUrl = i.IconUrl;
                }
                await WriteHeader(path, res, description, title, imageUrl, keyword, header);

                longDescription = description
                                  + AddAlternativeNames(i);

                longDescription += await GetRecentAuctions(i.Tag == "Unknown" || i.Tag == null?parameter : i.Tag);
            }
            else
            {
                if (path.Contains("/flipper"))
                {
                    title       = "Skyblock AH history auction flipper";
                    description = "Free auction house item flipper for Hypixel Skyblock";
                    keyword     = "flipper";
                }
                // unkown site, write the header
                await WriteStart(res, headerStart);
                await WriteHeader(path, res, description, title, imageUrl, keyword, header);
            }
            if (longDescription == null)
            {
                longDescription = description;
            }


            var newHtml = html + DETAILS_START
                          + BottomText(title, longDescription);

            await res.WriteEnd(newHtml);

            return(newHtml);
        }