From 3b47ec264efc800129b6fadbdfe125ae09587fd8 Mon Sep 17 00:00:00 2001 From: milimoe Date: Wed, 6 Nov 2024 19:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E6=8B=9F=20fungame?= =?UTF-8?q?=20=E7=9A=84=E5=9B=9E=E6=89=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ListeningTask/GroupMessageTask.cs | 110 +++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/src/ListeningTask/GroupMessageTask.cs b/src/ListeningTask/GroupMessageTask.cs index b457526..e6d64e0 100644 --- a/src/ListeningTask/GroupMessageTask.cs +++ b/src/ListeningTask/GroupMessageTask.cs @@ -112,7 +112,30 @@ namespace Milimoe.RainBOT.ListeningTask { Bot.FunGameSimulation = true; List msgs = await Bot.HttpGet>("https://api.milimoe.com/fungame/test?isweb=false") ?? []; - foreach (string msg in msgs) + List real = []; + int remain = 7; + string merge = ""; + for (int i = 0; i < msgs.Count - 2; i++) + { + remain--; + merge += msgs[i] + "\r\n"; + if (remain == 0) + { + real.Add(merge); + merge = ""; + if ((msgs.Count - i - 3) < 7) + { + remain = msgs.Count - i - 3; + } + else remain = 7; + } + } + if (msgs.Count > 2) + { + real.Add(msgs[^2]); + real.Add(msgs[^1]); + } + foreach (string msg in real) { await Bot.SendGroupMessage(e.group_id, "FunGame模拟", msg.Trim()); await Task.Delay(5500); @@ -126,6 +149,54 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } + if (e.detail.Length >= 11 && e.detail[..11].Equals("FunGame团队模拟", StringComparison.CurrentCultureIgnoreCase)) + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + if (!Bot.FunGameSimulation) + { + Bot.FunGameSimulation = true; + List msgs = await Bot.HttpGet>("https://api.milimoe.com/fungame/test?isweb=false&isteam=true") ?? []; + List real = []; + if (msgs.Count > 0) + { + real.Add(msgs[0]); + } + int remain = 7; + string merge = ""; + for (int i = 1; i < msgs.Count - 2; i++) + { + remain--; + merge += msgs[i] + "\r\n"; + if (remain == 0) + { + real.Add(merge); + merge = ""; + if ((msgs.Count - i - 3) < 7) + { + remain = msgs.Count - i - 3; + } + else remain = 7; + } + } + if (msgs.Count > 2) + { + real.Add(msgs[^2]); + real.Add(msgs[^1]); + } + foreach (string msg in real) + { + await Bot.SendGroupMessage(e.group_id, "FunGame团队模拟", msg.Trim()); + await Task.Delay(5500); + } + Bot.FunGameSimulation = false; + } + else + { + await Bot.SendGroupMessage(e.group_id, "FunGame团队模拟", "游戏正在模拟中,请勿重复请求!"); + } + return quick_reply; + } + if (e.detail.Length >= 3 && e.detail[..3].Equals("查数据", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; @@ -141,6 +212,43 @@ namespace Milimoe.RainBOT.ListeningTask return quick_reply; } + if (e.detail.Length >= 5 && e.detail[..5].Equals("查团队数据", StringComparison.CurrentCultureIgnoreCase)) + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + string detail = e.detail.Replace("查团队数据", "").Trim(); + if (int.TryParse(detail, out int id)) + { + string msg = (await Bot.HttpGet("https://api.milimoe.com/fungame/teamstats?id=" + id) ?? "").Trim(); + if (msg != "") + { + await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", msg); + } + } + return quick_reply; + } + + if (e.detail.Length >= 5 && e.detail[..5].Equals("查个人胜率", StringComparison.CurrentCultureIgnoreCase)) + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + string[] msg = await Bot.HttpGet("https://api.milimoe.com/fungame/winraterank?isteam=false") ?? []; + if (msg.Length > 0) + { + await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", string.Join("\r\n\r\n", msg)); + } + return quick_reply; + } + + if (e.detail.Length >= 5 && e.detail[..5].Equals("查团队胜率", StringComparison.CurrentCultureIgnoreCase)) + { + if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply; + string[] msg = await Bot.HttpGet("https://api.milimoe.com/fungame/winraterank?isteam=true") ?? []; + if (msg.Length > 0) + { + await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", string.Join("\r\n\r\n", msg)); + } + return quick_reply; + } + if (e.detail.Length >= 3 && e.detail[..3].Equals("查技能", StringComparison.CurrentCultureIgnoreCase)) { if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;