指令提示和查看运势优化

This commit is contained in:
milimoe 2024-03-24 16:02:17 +08:00
parent e1279906c1
commit 6b0048ca9d
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
3 changed files with 17 additions and 14 deletions

View File

@ -52,14 +52,14 @@ namespace Milimoe.RainBOT.Command
{ {
msg += "\r\n本群未启用OSM核心"; 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")) else if (GeneralSettings.IsRun && command.Contains(".osm stop"))
{ {
if (user_id == GeneralSettings.Master) if (user_id == GeneralSettings.Master)
{ {
string result = Execute_Worker(".osm stop", ""); 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); else Access_Denied(send_group, target_id);
} }
@ -68,7 +68,7 @@ namespace Milimoe.RainBOT.Command
if (user_id == GeneralSettings.Master) if (user_id == GeneralSettings.Master)
{ {
string result = Execute_Worker(".osm start", ""); 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); else Access_Denied(send_group, target_id);
} }
@ -109,8 +109,7 @@ namespace Milimoe.RainBOT.Command
{ {
await Bot.GetGroups(); await Bot.GetGroups();
await Bot.GetGroupMembers(); await Bot.GetGroupMembers();
string text = "刷新缓存完成。请注意,刷新缓存会导致正在禁言中的成员无法通过私聊忏悔命令解禁。"; SendMessage(send_group, target_id, "刷新缓存完成。请注意,刷新缓存会导致正在禁言中的成员无法通过私聊忏悔命令解禁。");
_ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", text) : Bot.SendFriendMessage(target_id, "OSM指令", text);
}); });
} }
else Access_Denied(send_group, target_id); else Access_Denied(send_group, target_id);
@ -120,8 +119,7 @@ namespace Milimoe.RainBOT.Command
if (user_id == GeneralSettings.Master) if (user_id == GeneralSettings.Master)
{ {
GeneralSettings.LoadSetting(); GeneralSettings.LoadSetting();
string text = "参数设定以及权限组重新加载完成。"; SendMessage(send_group, target_id, "参数设定以及权限组重新加载完成。");
_ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", text) : Bot.SendFriendMessage(target_id, "OSM指令", text);
} }
else Access_Denied(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 str = command.Replace(".osm set", "").Trim();
string[] strs = Regex.Split(str, @"\s+"); string[] strs = Regex.Split(str, @"\s+");
string result = Execute_Worker(".osm set", strs[0], strs.Length > 1 ? strs[1..] : []); 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); else Access_Denied(send_group, target_id);
} }
@ -167,7 +165,7 @@ namespace Milimoe.RainBOT.Command
else Access_Denied(send_group, target_id); else Access_Denied(send_group, target_id);
}); });
} }
else else if (command.Contains(".osm core") || command == ".osm")
{ {
// OSM核心信息 // OSM核心信息
if (send_group) if (send_group)
@ -186,6 +184,10 @@ namespace Milimoe.RainBOT.Command
} }
return; return;
} }
else
{
SendMessage(send_group, target_id, Execute_Worker(".osm missingcommand", ""));
}
return; return;
} }
@ -472,10 +474,11 @@ namespace Milimoe.RainBOT.Command
return "OSM Core指令格式不正确或传入的参数不支持。\r\n格式.osm <command> [part] [args...]"; return "OSM Core指令格式不正确或传入的参数不支持。\r\n格式.osm <command> [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指令", msg) : Bot.SendFriendMessage(target_id, "OSM指令", msg);
_ = send_group ? Bot.SendGroupMessage(target_id, "OSM指令", access_denied) : Bot.SendFriendMessage(target_id, "OSM指令", access_denied);
} }
public static string UpdateValue(string part, string old_value, string new_value, ConsoleColor color = ConsoleColor.Cyan) public static string UpdateValue(string part, string old_value, string new_value, ConsoleColor color = ConsoleColor.Cyan)

View File

@ -360,7 +360,7 @@ namespace Milimoe.RainBOT.ListeningTask
if (Daily.UserDailys.TryGetValue(qq, out string? daily) && daily != null) if (Daily.UserDailys.TryGetValue(qq, out string? daily) && daily != null)
{ {
GroupMessageContent content = new(e.group_id); 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); await Bot.SendGroupMessage(e.group_id, "查看运势", content);
} }
else else

View File

@ -3,7 +3,7 @@
public class OSMCore public class OSMCore
{ {
public const string version = "v1.0"; 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 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"; public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";