From 6b0048ca9dfebba2c35a68284039ee99e04e2361 Mon Sep 17 00:00:00 2001 From: milimoe Date: Sun, 24 Mar 2024 16:02:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E4=BB=A4=E6=8F=90=E7=A4=BA=E5=92=8C?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E8=BF=90=E5=8A=BF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command/MasterCommand.cs | 27 +++++++++++++++------------ src/ListeningTask/GroupMessageTask.cs | 2 +- src/Settings/OSMCore.cs | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Command/MasterCommand.cs b/src/Command/MasterCommand.cs index dce3140..85790bd 100644 --- a/src/Command/MasterCommand.cs +++ b/src/Command/MasterCommand.cs @@ -52,14 +52,14 @@ namespace Milimoe.RainBOT.Command { msg += "\r\n本群未启用OSM核心"; } - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM状态", msg) : Bot.SendFriendMessage(target_id, "OSM状态", msg); + SendMessage(send_group, target_id, msg); } else if (GeneralSettings.IsRun && command.Contains(".osm stop")) { if (user_id == GeneralSettings.Master) { string result = Execute_Worker(".osm stop", ""); - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", result) : Bot.SendFriendMessage(target_id, "OSM指令", result); + SendMessage(send_group, target_id, result); } else Access_Denied(send_group, target_id); } @@ -68,7 +68,7 @@ namespace Milimoe.RainBOT.Command if (user_id == GeneralSettings.Master) { string result = Execute_Worker(".osm start", ""); - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", result) : Bot.SendFriendMessage(target_id, "OSM指令", result); + SendMessage(send_group, target_id, result); } else Access_Denied(send_group, target_id); } @@ -109,8 +109,7 @@ namespace Milimoe.RainBOT.Command { await Bot.GetGroups(); await Bot.GetGroupMembers(); - string text = "刷新缓存完成。请注意,刷新缓存会导致正在禁言中的成员无法通过私聊忏悔命令解禁。"; - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", text) : Bot.SendFriendMessage(target_id, "OSM指令", text); + SendMessage(send_group, target_id, "刷新缓存完成。请注意,刷新缓存会导致正在禁言中的成员无法通过私聊忏悔命令解禁。"); }); } else Access_Denied(send_group, target_id); @@ -120,8 +119,7 @@ namespace Milimoe.RainBOT.Command if (user_id == GeneralSettings.Master) { GeneralSettings.LoadSetting(); - string text = "参数设定以及权限组重新加载完成。"; - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", text) : Bot.SendFriendMessage(target_id, "OSM指令", text); + SendMessage(send_group, target_id, "参数设定以及权限组重新加载完成。"); } else Access_Denied(send_group, target_id); } @@ -132,7 +130,7 @@ namespace Milimoe.RainBOT.Command string str = command.Replace(".osm set", "").Trim(); string[] strs = Regex.Split(str, @"\s+"); string result = Execute_Worker(".osm set", strs[0], strs.Length > 1 ? strs[1..] : []); - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", result) : Bot.SendFriendMessage(target_id, "OSM指令", result); + SendMessage(send_group, target_id, result); } else Access_Denied(send_group, target_id); } @@ -167,7 +165,7 @@ namespace Milimoe.RainBOT.Command else Access_Denied(send_group, target_id); }); } - else + else if (command.Contains(".osm core") || command == ".osm") { // OSM核心信息 if (send_group) @@ -186,6 +184,10 @@ namespace Milimoe.RainBOT.Command } return; } + else + { + SendMessage(send_group, target_id, Execute_Worker(".osm missingcommand", "")); + } return; } @@ -472,10 +474,11 @@ namespace Milimoe.RainBOT.Command return "OSM Core:指令格式不正确或传入的参数不支持。\r\n格式:.osm [part] [args...]"; } - public static void Access_Denied(bool send_group, long target_id) + public static void Access_Denied(bool send_group, long target_id) => SendMessage(send_group, target_id, "你没有权限使用此指令。"); + + public static void SendMessage(bool send_group, long target_id, string msg) { - string access_denied = "你没有权限使用此指令。"; - _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", access_denied) : Bot.SendFriendMessage(target_id, "OSM指令", access_denied); + _ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", msg) : Bot.SendFriendMessage(target_id, "OSM指令", msg); } public static string UpdateValue(string part, string old_value, string new_value, ConsoleColor color = ConsoleColor.Cyan) diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index 1bb1331..dd6d38f 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -360,7 +360,7 @@ namespace Milimoe.RainBOT.ListeningTask if (Daily.UserDailys.TryGetValue(qq, out string? daily) && daily != null) { GroupMessageContent content = new(e.group_id); - content.message.Add(new TextMessage(qq + "(" + Bot.GetMemberNickName(e.group_id, e.user_id) + ")的今日运势是:\r\n" + daily)); + content.message.Add(new TextMessage(Bot.GetMemberNickName(e.group_id, qq) + "(" + qq + ")的今日运势是:\r\n" + daily)); await Bot.SendGroupMessage(e.group_id, "查看运势", content); } else diff --git a/src/Settings/OSMCore.cs b/src/Settings/OSMCore.cs index f197e15..22395ba 100644 --- a/src/Settings/OSMCore.cs +++ b/src/Settings/OSMCore.cs @@ -3,7 +3,7 @@ public class OSMCore { public const string version = "v1.0"; - public const string version2 = "Patch1"; + public const string version2 = "Patch2 Test"; public const string time = "Mar. 22nd, 2024"; public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";