示例#1
0
 public Task <BotTimerResult> CreateBotTimer(BotTimer timer)
 {
     if (timer == null)
     {
         throw new ArgumentNullException(nameof(timer));
     }
     return(this.BotTimerClient.CreateAsync(timer));
 }
示例#2
0
 /// <summary>
 /// Update a single timer
 /// </summary>
 /// <returns></returns>
 public Task <BotTimerResult> UpdateBotTimer(string id, BotTimer timer)
 {
     if (string.IsNullOrWhiteSpace(id))
     {
         throw new ArgumentNullException(nameof(id));
     }
     if (timer == null)
     {
         throw new ArgumentNullException(nameof(timer));
     }
     return(this.BotTimerClient.UpdateAsync(id, timer));
 }
示例#3
0
 private void BotButton_Click(object sender, RoutedEventArgs e)
 {
     if (BotTimer != null)
     {
         BotTimer.Stop();
     }
     BotTimer = new DispatcherTimer
     {
         Interval = TimeSpan.FromMilliseconds(100)
     };
     BotStartTime       = Environment.TickCount;
     BotTimer.Tick     += Bottimer_Tick;
     BotTimer.IsEnabled = true;
 }
示例#4
0
        private void Bottimer_Tick(object sender, EventArgs e)
        {
            bool isReady = true;

            Bot.Content = TimerUtil.ChangeTimeContent(BotStartTime, GameStartTime, (bool)BotBoot.IsChecked, (bool)BotStar.IsChecked, out isReady);
            if (isReady)
            {
                if ((bool)chkVoice.IsChecked)
                {
                    voice.SpeakAsync("下路闪现好了");
                }
                BotTimer.Stop();
            }
            flowWindow.BotTime.Content = Bot.Content;
        }
示例#5
0
        private static void OnTimerElapsed(object sender, ElapsedEventArgs args)
        {
            try
            {
                using (BaseDBReader <BotTimer> timerReader = new BaseDBReader <BotTimer>())
                {
                    List <BotTimer> timers = timerReader.Where(bt => !bt.Expired);

                    for (int i = 0; i < timers.Count; i++)
                    {
                        BotTimer btimer = timers[i];

                        if (btimer.EndTime >= DateTime.UtcNow)
                        {
                            return;
                        }

                        btimer.Expired = true;
                        timerReader.Update(btimer);

                        string msg = $"<@!{btimer.CreatedByDiscordId}> ";

                        if (!string.IsNullOrEmpty(btimer.PingMessage))
                        {
                            msg += "Reminding you of: " + Environment.NewLine + btimer.PingMessage;
                        }

                        Coding.Discord.SendMessage((ulong)btimer.DiscordChannelId, msg);
                    }

                    timerReader.Save();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString(), LogLevel.ERROR);
            }
        }
示例#6
0
 private void Window_Closed(object sender, EventArgs e)
 {
     try
     {
         flowWindow.Close();
         if (TopTimer != null)
         {
             TopTimer.Stop();
         }
         if (JugTimer != null)
         {
             JugTimer.Stop();
         }
         if (MidTimer != null)
         {
             MidTimer.Stop();
         }
         if (BotTimer != null)
         {
             BotTimer.Stop();
         }
         if (SupTimer != null)
         {
             SupTimer.Stop();
         }
         if (GameTimer != null)
         {
             GameTimer.Stop();
         }
         this.hook_Main.UnInstallHook();
     }
     catch (Exception e2)
     {
         MessageBox.Show(e2.Message, "error code:2");
     }
 }
示例#7
0
 private DateTime GetExpirationDate(BotTimer timer)
 {
     return(timer.EndTime);
 }