Dissipate() 공개 메소드

public Dissipate ( Nuke nuke ) : void
nuke Nuke
리턴 void
예제 #1
0
파일: Nuke.cs 프로젝트: destinygg/bot
    private async void Load(TimeSpan duration, IEnumerable<Message> context) {
      Duration = duration;
      VictimList = new List<string>();
      Cancel = false;

      PreordainedVictims = context.Where(c => !c.IsMod).Where(s => Predicate(s.SanitizedText) || Predicate(s.OriginalText)).Select(x => x.SenderName).Distinct().ToList();
      Logger.Write(string.Join(",", PreordainedVictims), ConsoleColor.Cyan);

      try {
        var nuke = new AntiNuke(_messageProcessor);
        var cancelToken = nuke.CancellationTokenSource.Token;
        await Task.Run(() => nuke.Dissipate(this), cancelToken);
      } catch (TaskCanceledException e) {
        Logger.Write($"Cancelled!{Word}{Regex}");
        Logger.Write(e.Message);
      }

      _messageProcessor.Nukes.Add(this);
      _messageProcessor.Sender.Post(new PublicMessage($"{Tools.PrettyDeltaTime(duration)} missiles away!"));

      while (PreordainedVictims.Except(VictimList).Any()) {
        if (!Cancel) {
          var victim = PreordainedVictims.Except(VictimList).First();
          _messageProcessor.Sender.Post(new Mute(victim, Duration, null));
          VictimList.Add(victim);
          await Task.Delay(Settings.NukeLoopWait);
        } else {
          return;
        }
      }
      _messageProcessor.Sender.Post(new PublicMessage(
        $"{VictimList.Count} souls were vaporized in a single blinding instant"));
    }
예제 #2
0
파일: Nuke.cs 프로젝트: mikehrod2016/bot
        private async void Load(TimeSpan duration, IEnumerable <Message> context)
        {
            Duration   = duration;
            VictimList = new List <string>();
            Cancel     = false;

            PreordainedVictims = context.Where(c => !c.IsMod).Where(s => Predicate(s.SanitizedText) || Predicate(s.OriginalText)).Select(x => x.SenderName).Distinct().ToList();
            Logger.Write(string.Join(",", PreordainedVictims), ConsoleColor.Cyan);

            try {
                var nuke        = new AntiNuke(_messageProcessor);
                var cancelToken = nuke.CancellationTokenSource.Token;
                await Task.Run(() => nuke.Dissipate(this), cancelToken);
            } catch (TaskCanceledException e) {
                Logger.Write($"Cancelled!{Word}{Regex}");
                Logger.Write(e.Message);
            }

            _messageProcessor.Nukes.Add(this);
            _messageProcessor.Sender.Post(new PublicMessage($"{Tools.PrettyDeltaTime(duration)} missiles away!"));

            while (PreordainedVictims.Except(VictimList).Any())
            {
                if (!Cancel)
                {
                    var victim = PreordainedVictims.Except(VictimList).First();
                    _messageProcessor.Sender.Post(new Mute(victim, Duration, null));
                    VictimList.Add(victim);
                    await Task.Delay(Settings.NukeLoopWait);
                }
                else
                {
                    return;
                }
            }
            _messageProcessor.Sender.Post(new PublicMessage(
                                              $"{VictimList.Count} souls were vaporized in a single blinding instant"));
        }