예제 #1
0
        private void DonationTick(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                TipsResponse response = _tips.GetTips();

                foreach (Doc doc in response.docs)
                {
                    // Only track new donations...
                    if (!_trackedIDs.Contains(doc._id))
                    {
                        DateTime creationTime = DateTime.Parse(doc.createdAt);

                        // Only track donations, that came in after tracking started
                        if (creationTime > _startTime)
                        {
                            Buff buff = GetBuffFromMessage(doc.donation.message, doc.donation.amount);

                            if (buff != null)
                            {
                                _hacker.EnqueueBuff(buff);
                            }
                        }

                        _trackedIDs.Add(doc._id);
                    }
                }

                Thread.Sleep(1000);
            }
        }
예제 #2
0
        public TipsResponse GetTips()
        {
            RestRequest   request      = new RestRequest($"tips/{_accountID}", DataFormat.Json);
            IRestResponse response     = _streamElementsClient.Execute(request);
            TipsResponse  tipsResponse = JsonConvert.DeserializeObject <TipsResponse>(response.Content);

            return(tipsResponse);
        }