Revert "feat: 新版药材提示"

This reverts commit c5b3b9661b.
This commit is contained in:
LyMysterious
2026-07-25 19:37:53 +08:00
parent c5b3b9661b
commit 82aae20a9b
2 changed files with 18 additions and 30 deletions
@@ -24,7 +24,7 @@ namespace NapCatRobotClient.API.Controllers
{ {
using StreamReader reader = new(Request.Body); using StreamReader reader = new(Request.Body);
string body = await reader.ReadToEndAsync(); string body = await reader.ReadToEndAsync();
Log.Information($"接收到群消息:{body} \r\n"); //Log.Information($"接收到群消息:{body} \r\n");
bool result = await _dispatcherService.ReceiveMessageAndProcess(body); bool result = await _dispatcherService.ReceiveMessageAndProcess(body);
return Ok(result); return Ok(result);
} }
@@ -19,7 +19,7 @@ namespace NapCatRobotClient.Service.Group.TextProcess
if (string.IsNullOrWhiteSpace(groupMsg)) return false; if (string.IsNullOrWhiteSpace(groupMsg)) return false;
// 小小药材背包 // 小小药材背包
List<string> keyWord = new() { "拥有药材", "坊市数据" }; List<string> keyWord = new() { "拥有数量", "坊市数据" };
if (keyWord.All(k => groupMsg.Contains(k))) if (keyWord.All(k => groupMsg.Contains(k)))
{ {
RedisHelper.Client.Set(json["message_id"].ToString(), groupMsg, 60 * 10); RedisHelper.Client.Set(json["message_id"].ToString(), groupMsg, 60 * 10);
@@ -67,40 +67,28 @@ namespace NapCatRobotClient.Service.Group.TextProcess
private static async Task<bool> Herbal(string groupId, string text, bool upCmd) private static async Task<bool> Herbal(string groupId, string text, bool upCmd)
{ {
List<GoodsInfo> results = []; List<GoodsInfo> results = [];
var lines = text.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
var lines = text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines) foreach (var line in lines)
{ {
var content = line.Trim(); if (line.StartsWith("品级:"))
// 跳过无用行
if (content.StartsWith("鬼谷子的药材背包") ||
content.StartsWith("☆拥有药材☆") ||
content.StartsWith("第") ||
content.StartsWith("下一页"))
{ {
continue; _ = line.Substring("品级:".Length).Trim();
} }
else if (line.StartsWith("名字:"))
// 品级标题,例如:☆五品药材☆
if (Regex.IsMatch(content, @"^☆.+品药材☆$"))
{ {
// 如果以后需要品级,可以在这里记录 var name = line.Substring("名字:".Length).Trim();
// currentLevel = ... // 找到下一行的数量
continue; var index = Array.IndexOf(lines, line);
} if (index + 1 < lines.Length && lines[index + 1].StartsWith("拥有数量:"))
{
// 药材行,例如:天灵果 - 数量:4 炼金 | 坊市数据 var quantityLine = lines[index + 1];
var match = Regex.Match(content, @"^(.*?)\s*-\s*数量(\d+)"); var match = Regex.Match(quantityLine, @"拥有数量:(\d+)");
if (match.Success) if (match.Success)
{ {
results.Add(new GoodsInfo var quantity = match.Groups[1].Value;
{ results.Add(new() { Name = name, Num = Convert.ToInt32(quantity) });
Name = match.Groups[1].Value.Trim(), }
Num = int.Parse(match.Groups[2].Value) }
});
} }
} }