diff --git a/XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs b/XiaoXiaoRoBot/Cmd/GoodsUpShopCmd.cs
similarity index 77%
rename from XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs
rename to XiaoXiaoRoBot/Cmd/GoodsUpShopCmd.cs
index 0d41f04..6cb3ce9 100644
--- a/XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs
+++ b/XiaoXiaoRoBot/Cmd/GoodsUpShopCmd.cs
@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
+using Lagrange.Core.Common.Interface.Api;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;
using RoBot.Core;
@@ -6,7 +7,6 @@ using RoBot.Core.ConstValue;
using RoBot.Core.Helper;
using RoBot.Start.Global;
using RoBot.Start.LogConfig;
-using RoBot.Start.Message;
using RoBot.Start.Service.Dto;
namespace RoBot.Start.Cmd
@@ -14,26 +14,24 @@ namespace RoBot.Start.Cmd
///
/// 坊市上架命令
///
- public class QueryGoodsUpShopPriceCmd
+ public class GoodsUpShopCmd
{
-
public static async Task Execute(MessageChain chain)
{
try
{
- var systemConfig = GlobalConfig.ConfigSetting;
- if (chain.Count == 3 &&
- chain.FirstOrDefault(e => e is ForwardEntity) is ForwardEntity forward &&
- chain.FirstOrDefault(e => e is MentionEntity) is MentionEntity mention &&
- chain.FirstOrDefault(e => e is TextEntity) is TextEntity text)
+ List forwardEntities = chain.Where(o => o is ForwardEntity).ToList();
+ List textEntities = chain.Where(o => o is TextEntity).ToList();
+ if (chain.Count is 3 or 5 && forwardEntities.Count > 0 && textEntities.Count > 0)
{
- if ((text.Text.Contains("查上架") || text.Text.Contains("查价格")))
+ bool any = textEntities.Cast().ToList().Where(o => o.Text.Contains("查上架") || o.Text.Contains("查价格")).Any();
+ if (any)
{
+ if (textEntities.Count == 0) return false;
- var list = forward.Chain.Where(o => o is TextEntity);
- if (!list.Any()) return false;
+ ForwardEntity currentF = (ForwardEntity)forwardEntities[0];
- List convertList = list.Cast().ToList();
+ List convertList = currentF.Chain.Where(o => o is TextEntity).Cast().ToList();
convertList = convertList.Where(o => string.IsNullOrWhiteSpace(o.Text) is false)
.ToList();
if (convertList.Count > 0)
@@ -45,7 +43,7 @@ namespace RoBot.Start.Cmd
(desc.Contains("名字") && desc.Contains("拥有数量"))
)
{
- _ = Herbal(desc);
+ _ = Herbal(chain, desc);
}
}
}
@@ -63,17 +61,15 @@ namespace RoBot.Start.Cmd
/// 计算药材
///
///
- private static async Task Herbal(string text)
+ private static async Task Herbal(MessageChain chain, string text)
{
List results = [];
-
- string currentGrade = "";
var lines = text.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
{
if (line.StartsWith("品级:"))
{
- currentGrade = line.Substring("品级:".Length).Trim();
+ _ = line.Substring("品级:".Length).Trim();
}
else if (line.StartsWith("名字:"))
{
@@ -120,7 +116,9 @@ namespace RoBot.Start.Cmd
msg += $"到账约:{Utils.FormatNumberToChineseUnit(totalPrice - fee)}";
var systemConfig = GlobalConfig.ConfigSetting;
var bot = GlobalConfig.BotContext;
- await bot.SendMsg((uint)systemConfig.GroupQQ, msg);
+
+ var groupMessageChain = MessageBuilder.Group((uint)systemConfig.GroupQQ).Forward(chain).Text(msg);
+ await bot.SendMessage(groupMessageChain.Build());
}
return await Task.FromResult(true);
diff --git a/XiaoXiaoRoBot/Cmd/InertOrUpdateGoodsCmd.cs b/XiaoXiaoRoBot/Cmd/InertOrUpdateGoodsInfoCmd.cs
similarity index 96%
rename from XiaoXiaoRoBot/Cmd/InertOrUpdateGoodsCmd.cs
rename to XiaoXiaoRoBot/Cmd/InertOrUpdateGoodsInfoCmd.cs
index daadd19..06218df 100644
--- a/XiaoXiaoRoBot/Cmd/InertOrUpdateGoodsCmd.cs
+++ b/XiaoXiaoRoBot/Cmd/InertOrUpdateGoodsInfoCmd.cs
@@ -8,7 +8,7 @@ namespace RoBot.Start.Cmd
///
/// 保存或更新物品价格
///
- public class InertOrUpdateGoodsCmd
+ public class InertOrUpdateGoodsInfoCmd
{
public static async Task Execute(MessageChain chain)
{
diff --git a/XiaoXiaoRoBot/Cmd/QueryGoodsInfoPriceCmd.cs b/XiaoXiaoRoBot/Cmd/QueryGoodsPriceCmd.cs
similarity index 98%
rename from XiaoXiaoRoBot/Cmd/QueryGoodsInfoPriceCmd.cs
rename to XiaoXiaoRoBot/Cmd/QueryGoodsPriceCmd.cs
index b9d7624..e88ff24 100644
--- a/XiaoXiaoRoBot/Cmd/QueryGoodsInfoPriceCmd.cs
+++ b/XiaoXiaoRoBot/Cmd/QueryGoodsPriceCmd.cs
@@ -12,7 +12,7 @@ namespace RoBot.Start.Cmd
///
/// 查看物品信息命令 价格/数据更新时间
///
- public class QueryGoodsInfoPriceCmd
+ public class QueryGoodsPriceCmd
{
public static async Task Execute(MessageChain chain)
{
diff --git a/XiaoXiaoRoBot/Program.cs b/XiaoXiaoRoBot/Program.cs
index 26ac5cc..486d365 100644
--- a/XiaoXiaoRoBot/Program.cs
+++ b/XiaoXiaoRoBot/Program.cs
@@ -90,13 +90,13 @@ async Task HandleGroupMessage(MessageChain chain)
await WantedPriceCmd.Execute(chain);
// 坊市生成上架命令
- await QueryGoodsUpShopPriceCmd.Execute(chain);
+ await GoodsUpShopCmd.Execute(chain);
// 保存或更新物品价格
- await InertOrUpdateGoodsCmd.Execute(chain);
+ await InertOrUpdateGoodsInfoCmd.Execute(chain);
// 查看物品信息命令 价格/数据更新时间
- await QueryGoodsInfoPriceCmd.Execute(chain);
+ await QueryGoodsPriceCmd.Execute(chain);
// 灵田结算价格
await LingTianCmd.Execute(chain);