Esempio n. 1
0
        public async Task CheckDailyPublisher(bool force = false)
        {
            await Task.Delay(TimeSpan.FromSeconds(10d), _token);

            while (true)
            {
                if (_botData.LastPublisherCheck < DateTime.Now - TimeSpan.FromDays(1d) || force)
                {
                    uint  count = _databaseService.GetPublisherAdCount();
                    ulong id;
                    uint  rand;
                    do
                    {
                        rand = (uint)_random.Next((int)count);
                        id   = _databaseService.GetPublisherAd(rand).userId;
                    } while (_botData.LastPublisherId.Contains(id));

                    await _publisherService.PostAd(rand);

                    await _loggingService.LogAction("Posted new daily publisher ad.", true, false);

                    _botData.LastPublisherCheck = DateTime.Now;
                    _botData.LastPublisherId.Add(id);
                }

                if (_botData.LastPublisherId.Count > 10)
                {
                    _botData.LastPublisherId.RemoveAt(0);
                }

                if (force)
                {
                    return;
                }
                await Task.Delay(TimeSpan.FromMinutes(5d), _token);
            }
        }
Esempio n. 2
0
 public async Task PostAd(uint id)
 {
     (uint, ulong)ad = _databaseService.GetPublisherAd(id);
     await PublisherAdvertising(ad.Item1, ad.Item2);
 }