Exemple #1
0
 public static void CheckMethod()
 {
     while (true)
     {
         Thread.Sleep(CheckSpan);
         lock (_lock)
         {
             Task.Run(async() =>
             {
                 var now  = DateTime.Now;
                 var bots = Program.QQServer.GetBotList();
                 var msgs = await TipMessageService.GetTipMessages(TipMessage.TipTargetType.QQGroup, now);
                 foreach (var msg in msgs)
                 {
                     foreach (var bot in bots)
                     {
                         var api = Program.QQServer.GetSoraApi(bot);
                         if (await api.CheckHasGroup(msg.TargetID))
                         {
                             ConsoleLog.Debug("TipMessage", $"Send tip message to group {msg.TargetID} with bot {bot}");
                             var m = new ArrayList
                             {
                                 "[Tip Message]",
                                 Environment.NewLine
                             };
                             int n = 0;
                             int i = msg.Message.IndexOf("[@all]", n);
                             while (i < msg.Message.Length && i >= n)
                             {
                                 m.Add(msg.Message[n..i]);
                                 m.Add(CQCode.CQAtAll());
                                 i = msg.Message.IndexOf("[@all]", n = i + 6);
                             }
                             m.Add(msg.Message[n..]);
Exemple #2
0
        public static async void TipList(SoraMessage e)
        {
            var list = await TipMessageService.GetTipMessages(TipTargetType.QQGroup, e.SourceGroup.Id);

            if (list.Length > 0)
            {
                var sb = new StringBuilder("本群现有的所有的提醒项目:");
                foreach (var tip in list)
                {
                    sb.AppendLine().AppendLine($"[ID:{tip.Id}]");
                    if (tip.Duplicate)
                    {
                        sb.AppendLine($"下一次提醒时间:{tip.TipTime:yyyy-MM-dd HH:mm:ss}");
                        sb.AppendLine($"提醒间隔:{tip.Interval.Days}天{tip.Interval.Hours}时{tip.Interval.Minutes}分{tip.Interval.Seconds}秒");
                        sb.AppendLine($"提醒结束于:{tip.EndTime:yyyy-MM-dd HH:mm:ss}");
                    }
                    else
                    {
                        sb.AppendLine($"提醒时间:{tip.TipTime:yyyy-MM-dd HH:mm:ss}");
                    }
                    sb.AppendLine("提醒内容:");
                    sb.Append(tip.Message);
                }
                await e.Reply(sb.ToString());
            }
            else
            {
                await e.Reply("本群目前不存在提示信息");
            }
        }