fix: 小小 药材价格查询 秘境通知修复
This commit is contained in:
+11
-5
@@ -1,4 +1,5 @@
|
||||
using Furion.Logging;
|
||||
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
|
||||
|
||||
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
{
|
||||
@@ -16,18 +17,23 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
if (message.Contains("不鼓励不保障"))
|
||||
{
|
||||
JObject json = JObject.Parse(message);
|
||||
message = json["message"]?.ToString();
|
||||
message = JArray.Parse(message).FirstOrDefault(o => o["type"].ToString() == "text" && !string.IsNullOrWhiteSpace(o["data"]["text"].ToString()))["data"]["text"]?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(message)) return false;
|
||||
string jsonMessage = json["message"]?.ToString();
|
||||
|
||||
jsonMessage = JArray.Parse(jsonMessage)
|
||||
.Where(x => x?["type"]?.ToString() == "text")
|
||||
.Select(x => x?["data"]?["text"]?.ToString())
|
||||
.FirstOrDefault(t => !string.IsNullOrWhiteSpace(t) && new string[] { "不鼓励不保障" }.All(k => t.Contains(k)));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(jsonMessage)) return false;
|
||||
|
||||
List<GoodsInfo> results = new();
|
||||
|
||||
MatchCollection matches = Regex.Matches(message);
|
||||
MatchCollection matches = Regex.Matches(jsonMessage);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
string price = match.Groups[1].Value;
|
||||
string name = match.Groups[2].Value.Replace("\u200b", "").Replace("\u200c", "").Replace("\u200d", ""); // 去除零宽字符
|
||||
string name = match.Groups[2].Value.Replace("\u200b", "").Replace("\u200c", "").Replace("\u200d", "").Replace("?", ""); // 去除零宽字符
|
||||
GoodsInfo gds = new()
|
||||
{
|
||||
Name = name,
|
||||
|
||||
Reference in New Issue
Block a user