public void Outbid(SubscribeItem sub, SaveAuction auction, SaveBids bid) { var outBidBy = auction.HighestBidAmount - bid.Amount; var text = $"You were outbid on {auction.ItemName} by {PlayerSearch.Instance.GetNameWithCache(auction.Bids.FirstOrDefault().Bidder)} by {outBidBy}"; Task.Run(() => Send(sub.UserId, "Outbid", text, AuctionUrl(auction), ItemIconUrl(auction.Tag), FormatAuction(auction))).ConfigureAwait(false); }
private static void AddSubscription(SubscribeItem item, ConcurrentDictionary <string, ConcurrentBag <SubscribeItem> > target) { var itemId = item.TopicId; var priceChange = target.GetOrAdd(itemId, itemId => new ConcurrentBag <SubscribeItem>()); priceChange.Add(item); }
private void AddSubscription(HypixelContext context, SubscribeItem item) { if (item.Type.HasFlag(SubscribeItem.SubType.OUTBID)) { AddSubscription(item, outbid); } else if (item.Type.HasFlag(SubscribeItem.SubType.SOLD)) { AddSubscription(item, Sold); } else if (item.Type.HasFlag(SubscribeItem.SubType.PRICE_LOWER_THAN) || item.Type.HasFlag(SubscribeItem.SubType.PRICE_HIGHER_THAN)) { AddSubscription(item, PriceUpdate); } else if (item.Type.HasFlag(SubscribeItem.SubType.AUCTION)) { AddSubscription(item, AuctionSub); } else if (item.Type.HasFlag(SubscribeItem.SubType.PLAYER)) { AddSubscription(item, UserAuction); } else { Console.WriteLine("ERROR: unkown subscibe type " + item.Type); } }
public void AddNew(SubscribeItem subscription) { using (var context = new HypixelContext()) { context.SubscribeItem.Add(subscription); context.SaveChanges(); AddSubscription(context, subscription); } }
internal void AuctionPriceAlert(SubscribeItem sub, SaveAuction auction) { var text = $"New Auction for {auction.ItemName} for {auction.StartingBid}"; Task.Run(() => Send(sub.UserId, $"Price Alert", text, AuctionUrl(auction), ItemIconUrl(auction.Tag), FormatAuction(auction))).ConfigureAwait(false); }
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); }
internal void AuctionOver(SubscribeItem sub, SaveAuction auction) { var text = $"Highest bid is {auction.HighestBidAmount}"; Task.Run(() => Send(sub.UserId, $"Auction for {auction.ItemName} ended", text, AuctionUrl(auction), ItemIconUrl(auction.Tag), FormatAuction(auction))).ConfigureAwait(false); }
public void NewBid(SubscribeItem sub, SaveAuction auction, SaveBids bid) { var text = $"New bid on {auction.ItemName} by {PlayerSearch.Instance.GetNameWithCache(auction.Bids.FirstOrDefault().Bidder)} for {auction.HighestBidAmount}"; Task.Run(() => Send(sub.UserId, "New bid", text, AuctionUrl(auction), ItemIconUrl(auction.Tag), auction)).ConfigureAwait(false); }
internal void Sold(SubscribeItem sub, SaveAuction auction) { var text = $"{auction.ItemName} was sold to {PlayerSearch.Instance.GetNameWithCache(auction.Bids.FirstOrDefault().Bidder)} for {auction.HighestBidAmount}"; Task.Run(() => Send(sub.UserId, "Item Sold", text, AuctionUrl(auction), ItemIconUrl(auction.Tag), FormatAuction(auction))).ConfigureAwait(false); }
private static bool SubscribeItemEqual(int userId, string topic, SubscribeItem.SubType type, SubscribeItem s) { return(s.UserId == userId && s.TopicId == topic && s.Type == type); }