Exemple #1
0
 void SellFromQueue()
 {
     while (parent.IsRunning())
     {
         if (Tasking.WaitForFalseOrTimeout(parent.IsRunning, 1000).Result)
         {
             continue;
         }
         while (refreshPrice.IsEmpty && toBeSold.IsEmpty)
         {
             Thread.Sleep(1000);
         }
         if (!refreshPrice.IsEmpty)
         {
             lock (RefreshItemsLock) {
                 List <Tuple <string, int> > items = new List <Tuple <string, int> >();
                 items = new List <Tuple <string, int> >();
                 while (refreshPrice.TryDequeue(out TMTrade trade))
                 {
                     items.Add(new Tuple <string, int>(trade.ui_id, 0));
                 }
                 /*JOBject obj = */
                 Protocol.MassSetPriceById(items);
             }
         }
         else if (toBeSold.TryDequeue(out Inventory.SteamItem item))
         {
             if (cachedInventory != null && cachedTradableCount < stopsell)
             {
                 while (toBeSold.TryDequeue(out item))
                 {
                     ;                                  //clear whole queue
                 }
                 Protocol.RemoveAll();
                 continue;
             }
             int price = GetMySellPrice(item);
             if (price != -1)
             {
                 try {
                     string[] ui_id = item.ui_id.Split('_');
                     if (Protocol.SellNew(long.Parse(ui_id[1]), long.Parse(ui_id[2]), price))
                     {
                         Log.Success($"New {item.i_market_name} is on sale for {price}");
                     }
                     else
                     {
                         Log.ApiError(TMBot.RestartPriority.SmallError, "Could not sell new item, enqueuing it again.");
                     }
                 } catch {
                 }
             }
         }
     }
 }
Exemple #2
0
        public JObject Test(string api)
        {
            string url = $"/api/Test/?key={GetApi()}";

            try {
                string response = Utility.Request.Get(Consts.MARKETENDPOINT + url);
                if (response == null)
                {
                    return(new JObject {
                        ["success"] = false
                    });
                }
                JObject temp = JObject.Parse(response);
                return(temp);
            } catch (Exception ex) {
                Log.ApiError(ex.Message);
            }
            return(new JObject {
                ["success"] = false
            });
        }