Beispiel #1
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            bool stopThread = message == "stop";

            CurrentMarketThread = new Thread(t =>
            {
                while (!stopThread)
                {
                    bool cancel = false;
                    int start   = 0;
                    int amount  = 100;
                    while (!cancel)
                    {
                        try
                        {
                            var mResp            = Bot.GetMarketResponse(message, start, amount);
                            var inexpensiveSkins = mResp.Listings.Where(v => v.SubTotal <= 5);
                            Log.Success("Found " + inexpensiveSkins.Count() + " in the range from " + start + " to " + (start + amount));
                            if (!inexpensiveSkins.Any())
                            {
                                cancel = true;
                            }
                            else
                            {
                                foreach (var listing in inexpensiveSkins)
                                {
                                    if (stopThread)
                                    {
                                        return;
                                    }
                                    if (ReplyReceived)
                                    {
                                        ReplyReceived = false;
                                        BuyIfLowerThan(listing, 0.01f);
                                        Log.Info("Sleeping 2 secs");
                                        Thread.Sleep(2000);
                                    }
                                    else
                                    {
                                        Log.Info("No reply, sleeping 10 secs");
                                        Thread.Sleep(10000);
                                        BuyIfLowerThan(listing, 0.01f);
                                        Log.Info("Sleeping 2 secs");
                                        Thread.Sleep(2000);
                                    }
                                }
                                start = start + amount;
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Warn("Error occurred in buy thread: " + e);
                        }
                    }
                }
            });
            CurrentMarketThread.Start();
        }