Beispiel #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 {
                 }
             }
         }
     }
 }
Beispiel #2
0
 public void Initialize()
 {
     logger.Info("Initializing core");
     InitializeEndpoints();
     httpListener.Start();
     VK.Init();
     logger.Success("Started serving");
     tokenSource = new CancellationTokenSource();
     ct          = tokenSource.Token;
     listener    = Task.Factory.StartNew(Listen, ct);
 }