From d6d7beaa6facc23c8c363fce1827d7df3995f91c Mon Sep 17 00:00:00 2001 From: milimoe Date: Thu, 24 Jul 2025 01:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OshimaWebAPI/Controllers/FunGameController.cs | 2 +- OshimaWebAPI/Services/RainBOTService.cs | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index 8795cab..69d3628 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -2783,7 +2783,7 @@ namespace Oshima.FunGame.WebAPI.Controllers FunGameService.SetUserConfigAndReleaseSemaphoreSlim(userid, pc, user); string msg = ""; - if (user.IsAdmin || userid > 0) + if (user.IsAdmin) { PluginConfig pc2 = FunGameService.GetUserConfig(targetid, out _); if (pc2.Count > 0) diff --git a/OshimaWebAPI/Services/RainBOTService.cs b/OshimaWebAPI/Services/RainBOTService.cs index b204979..05b2d3b 100644 --- a/OshimaWebAPI/Services/RainBOTService.cs +++ b/OshimaWebAPI/Services/RainBOTService.cs @@ -187,8 +187,19 @@ namespace Oshima.FunGame.WebAPI.Services if (e.Detail.StartsWith("添加公告")) { e.UseNotice = false; + string author = "FunGame"; + FunGameConstant.UserIdAndUsername.TryGetValue(uid, out User? user); + if (user is null || (!user.IsAdmin && !user.IsOperator)) + { + await SendAsync(e, "公告", "你没有权限使用此指令。"); + return true; + } + else + { + author = user.Username; + } string detail = e.Detail.Replace("添加公告", "").Trim(); - string[] strings = detail.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); + string[] strings = detail.Split(["\r\n", "\r", "\n"], StringSplitOptions.RemoveEmptyEntries); string title = $"#Unknown"; if (strings.Length > 1) { @@ -210,11 +221,6 @@ namespace Oshima.FunGame.WebAPI.Services } detail = strings[0].Trim(); } - string author = "FunGame"; - if (FunGameConstant.UserIdAndUsername.TryGetValue(uid, out User? user) && user != null) - { - author = user.Username; - } FunGameService.Notices.Add(title, new NoticeModel() { Title = title,