Пример #1
0
        private async Task StartTwitterPoll(MessageCreateEventArgs e)
        {
            bool alreadyStarted = false;

            using (await _asyncLock.LockAsync())
            {
                alreadyStarted = _swtorAvailablePoll != null;
                if (!alreadyStarted)
                {
                    _swtorAvailablePoll = new SwtorAvailablePoll();
                    _swtorAvailablePoll.ServersAvailable += SwtorAvailablePoll_ServersAvailable;
                    _swtorAvailablePoll.Start(e.Channel);
                }
            }
            if (alreadyStarted)
            {
                await SendError(e, "I am already monitoring twitter");
            }
            else
            {
                await e.Message.RespondAsync($"{DiscordText.OkHand} Monitoring twitter for 'servers are available' tweet....");
            }
        }
Пример #2
0
 private async Task EndTwitterPoll()
 {
     try { await _swtorAvailablePoll.Stop(); } catch (TaskCanceledException) { }
     _swtorAvailablePoll.Dispose();
     _swtorAvailablePoll = null;
 }