From 57c2ec2a0a761e1dd44ad65305f644b7cb029c45 Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 16 Nov 2024 14:51:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93=E5=AD=98=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ListeningTask/GroupMessageTask.cs | 24 +++++++++++++++--------- src/Settings/Bot.cs | 13 +++++++++++++ src/Settings/OSMCore.cs | 2 +- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index 8a56182..07a67d6 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -328,33 +328,39 @@ namespace Milimoe.RainBOT.ListeningTask if (e.detail == "创建存档") { - if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/cjcd?qq={e.user_id}&name={e.sender.nickname}", "") ?? "").Trim(); if (msg != "") { - await Bot.SendGroupMessage(e.group_id, "创建存档", msg); + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "创建存档", msg); } return quick_reply; } if (e.detail == "抽卡") { - if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/ck?qq={e.user_id}", "") ?? "").Trim(); if (msg != "") { - await Bot.SendGroupMessage(e.group_id, "抽卡", msg); + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "抽卡", msg); } return quick_reply; } - if (e.detail == "查看库存") + if (e.detail.Length >= 4 && e.detail[..4].Equals("查看库存", StringComparison.CurrentCultureIgnoreCase)) { - if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; - string msg = (await Bot.HttpPost($"https://api.milimoe.com/fungame/ckkc?qq={e.user_id}", "") ?? "").Trim(); - if (msg != "") + string detail = e.detail.Replace("查看库存", "").Trim(); + List msgs = []; + if (int.TryParse(detail, out int page)) { - await Bot.SendGroupMessage(e.group_id, "查看库存", msg); + msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/ckkc2?qq={e.user_id}&page={page}", "") ?? []; + } + else + { + msgs = await Bot.HttpPost>($"https://api.milimoe.com/fungame/ckkc2?qq={e.user_id}&page=1", "") ?? []; + } + if (msgs.Count > 0) + { + await Bot.SendGroupMessageAt(e.user_id, e.group_id, "查看库存", string.Join("\r\n", msgs)); } return quick_reply; } diff --git a/src/Settings/Bot.cs b/src/Settings/Bot.cs index 44eca0f..da7e43d 100644 --- a/src/Settings/Bot.cs +++ b/src/Settings/Bot.cs @@ -167,6 +167,19 @@ namespace Milimoe.RainBOT.Settings } await SendMessage(SupportedAPI.send_group_msg, group_id, function, content, true); } + + public static async Task SendGroupMessageAt(long at_id, long group_id, string function, string text, int delay = 0) + { + GroupMessageContent content = new(group_id); + content.message.Add(new AtMessage(at_id)); + content.message.Add(new TextMessage(text)); + if (delay > 0) + { + await Task.Delay(delay); + if (!GeneralSettings.IsRun) return; + } + await SendMessage(SupportedAPI.send_group_msg, group_id, function, content, true); + } public static async Task SendGroupMessage(long group_id, string function, IContent content) => await SendMessage(SupportedAPI.send_group_msg, group_id, function, content, true); diff --git a/src/Settings/OSMCore.cs b/src/Settings/OSMCore.cs index 9d00eeb..228e544 100644 --- a/src/Settings/OSMCore.cs +++ b/src/Settings/OSMCore.cs @@ -6,7 +6,7 @@ namespace Milimoe.RainBOT.Settings public class OSMCore { public const string version = "v1.0"; - public const string version2 = "Patch11"; + public const string version2 = "Patch12"; public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {GetBuiltTime(Assembly.GetExecutingAssembly().Location)}\r\nSee: https://github.com/milimoe";