From a5df62b5db485abb57147b6b6f0702856bd2489f Mon Sep 17 00:00:00 2001 From: milimoe Date: Wed, 3 Jul 2024 00:10:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A012=E7=82=B9=E5=A4=A7=E6=8C=91?= =?UTF-8?q?=E6=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command/MasterCommand.cs | 2 +- src/ListeningTask/GroupMessageTask.cs | 28 +++++++++++++++++++++++++++ src/Main.cs | 3 +++ src/Settings/Bot.cs | 27 ++++++++++++++++++++++++++ src/Settings/GeneralSettings.cs | 13 ++++++++++++- src/Settings/OSMCore.cs | 4 ++-- 6 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index c85e97e..cb66eb6 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -210,7 +210,7 @@ namespace Milimoe.RainBOT.Command { GeneralSettings.ShowAccessGroupMemberList(target_id, part, send_group); } - if (part.Contains("ignore")) + else if (part.Contains("ignore")) { Ignore.ShowList(target_id, part, send_group); } diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index b379a2f..f751a93 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -77,6 +77,34 @@ namespace Milimoe.RainBOT.ListeningTask return; } + // 12点大挑战 + if (e.detail == "加入12点" || e.detail == "加入12点大挑战") + { + if (GeneralSettings.Challenge12ClockGroup.Contains(e.user_id)) + { + _ = Bot.SendGroupMessage(e.group_id, "12点大挑战", "请勿重复加入。"); + } + else + { + GeneralSettings.Challenge12ClockGroup.Add(e.user_id); + _ = Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功加入~\r\n发送【退出12点】退出挑战。"); + GeneralSettings.SaveConfig(); + } + return; + } + else if ((e.detail == "退出12点" || e.detail == "退出12点大挑战") && GeneralSettings.Challenge12ClockGroup.Contains(e.user_id)) + { + GeneralSettings.Challenge12ClockGroup.Remove(e.user_id); + _ = Bot.SendGroupMessage(e.group_id, "12点大挑战", "你已成功退出~\r\n发送【加入12点】即可再次参加。"); + GeneralSettings.SaveConfig(); + return; + } + else if (e.detail == "12点大挑战") + { + _ = Bot.SendGroupMessage(e.group_id, "12点大挑战", "欢迎加入12点大挑战。参加本挑战后,你将在每晚的12点获得8小时禁言和优质的睡眠,确保第二天的精神饱满!\r\n发送【加入12点】即可参加。"); + return; + } + // 发图API if (e.detail == "来图") { diff --git a/src/Main.cs b/src/Main.cs index 599b7e5..37b60de 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -1,4 +1,5 @@ using Milimoe.OneBot.Framework; +using Milimoe.OneBot.Framework.Interface; using Milimoe.OneBot.Model.Content; using Milimoe.OneBot.Model.Message; using Milimoe.OneBot.Model.Other; @@ -140,6 +141,8 @@ try Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("已重置所有人的今日运势。"); Console.ForegroundColor = ConsoleColor.Gray; + // 发放12点大挑战的奖励 + await Bot.Send12ClockPresents(); } if (now.Hour == 0 && now.Minute == 1) { diff --git a/src/Settings/Bot.cs b/src/Settings/Bot.cs index ec825b2..ff0c232 100644 --- a/src/Settings/Bot.cs +++ b/src/Settings/Bot.cs @@ -327,5 +327,32 @@ namespace Milimoe.RainBOT.Settings } else await SendGroupMessage(group_id, "OSM指令", "你没有权限使用此指令。"); } + + public static async Task Send12ClockPresents() + { + foreach (long group_id in GroupMembers.Keys) + { + List list = []; + foreach (Member m in GroupMembers[group_id]) + { + if (GeneralSettings.Challenge12ClockGroup.Contains(m.user_id)) + { + SetGroupBanContent content = new(group_id, m.user_id, 28800); + list.Add(content); + await Task.Delay(3000); + if (MuteRecall.Muted[group_id].ContainsKey(m.user_id)) MuteRecall.Muted[group_id][m.user_id] = GeneralSettings.BotQQ; + else MuteRecall.Muted[group_id].Add(m.user_id, GeneralSettings.BotQQ); + } + } + if (list.Count > 0) + { + await SendMessage(SupportedAPI.set_group_ban, group_id, "12点大挑战", list, true); + await SendGroupMessage(group_id, "12点大挑战", "12点大挑战的奖励现已发放!\r\n添加Bot为好友即可享受私聊【忏悔】解除禁言的特权。\r\n发送【退出12点】即可退出挑战!"); + } + } + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("已向12点大挑战的成员发放奖励。"); + Console.ForegroundColor = ConsoleColor.Gray; + } } } diff --git a/src/Settings/GeneralSettings.cs b/src/Settings/GeneralSettings.cs index 6d22db3..f52f004 100644 --- a/src/Settings/GeneralSettings.cs +++ b/src/Settings/GeneralSettings.cs @@ -1,4 +1,5 @@ -using Milimoe.OneBot.Framework.Utility; +using System.Drawing; +using Milimoe.OneBot.Framework.Utility; namespace Milimoe.RainBOT.Settings { @@ -51,6 +52,8 @@ namespace Milimoe.RainBOT.Settings public static List SayNoAccessGroup { get; set; } = []; public static List OSMCoreGroup { get; set; } = []; + + public static List Challenge12ClockGroup { get; set; } = []; public static PluginConfig Configs { get; set; } = new("rainbot", "config"); @@ -150,6 +153,10 @@ namespace Milimoe.RainBOT.Settings { OSMCoreGroup = (List)value; } + if (configs.TryGetValue("Challenge12ClockGroup", out value) && value != null) + { + Challenge12ClockGroup = (List)value; + } } public static void SaveConfig() @@ -176,6 +183,7 @@ namespace Milimoe.RainBOT.Settings Configs.Add("RecallAccessGroup", RecallAccessGroup); Configs.Add("SayNoAccessGroup", SayNoAccessGroup); Configs.Add("OSMCoreGroup", OSMCoreGroup); + Configs.Add("Challenge12ClockGroup", Challenge12ClockGroup); Configs.Save(); } @@ -199,6 +207,9 @@ namespace Milimoe.RainBOT.Settings case "osmcoregroup": list = OSMCoreGroup; break; + case "challenge12clockgroup": + list = Challenge12ClockGroup; + break; } string msg = list.Count > 0 ? "权限组" + group + "拥有以下成员:" + "\r\n" + string.Join("\r\n", list) : "此权限组不存在或没有任何成员。"; _ = isgroup ? Bot.SendGroupMessage(target, "显示列表成员", msg) : Bot.SendFriendMessage(target, "显示列表成员", msg); diff --git a/src/Settings/OSMCore.cs b/src/Settings/OSMCore.cs index 18d9dbf..1f0d498 100644 --- a/src/Settings/OSMCore.cs +++ b/src/Settings/OSMCore.cs @@ -3,8 +3,8 @@ public class OSMCore { public const string version = "v1.0"; - public const string version2 = "Patch7 Test2"; - public const string time = "July 1st, 2024"; + public const string version2 = "Patch7"; + public const string time = "July 3rd, 2024"; public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe"; }