|
|
|
|
@ -6,6 +6,7 @@ using RoBot.Core.ConstValue;
|
|
|
|
|
using RoBot.Core.Helper;
|
|
|
|
|
using RoBot.Start.Dto.Wanted;
|
|
|
|
|
using RoBot.Start.Global;
|
|
|
|
|
using RoBot.Start.LogConfig;
|
|
|
|
|
using RoBot.Start.Message;
|
|
|
|
|
using RoBot.Start.Service.Dto;
|
|
|
|
|
|
|
|
|
|
@ -18,55 +19,61 @@ namespace RoBot.Start.Cmd
|
|
|
|
|
{
|
|
|
|
|
public static async Task<bool> Execute(MessageChain chain)
|
|
|
|
|
{
|
|
|
|
|
var textEntities = chain.Where(o => o is TextEntity).ToList();
|
|
|
|
|
List<TextEntity> convertList = textEntities.Cast<TextEntity>().ToList().Where(o => o.Text.Contains("道友的个人悬赏令") || o.Text.Contains("天机悬赏令")).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in convertList)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<WantedTaskInfo> wantedTasks = new();
|
|
|
|
|
if (item.Text.Contains("个人悬赏令"))
|
|
|
|
|
{
|
|
|
|
|
wantedTasks = await SingleWanted(item.Text);
|
|
|
|
|
}
|
|
|
|
|
else if (item.Text.Contains("天机悬赏令"))
|
|
|
|
|
{
|
|
|
|
|
wantedTasks = await SpecialWanted(item.Text);
|
|
|
|
|
}
|
|
|
|
|
if (wantedTasks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var systemConfig = GlobalConfig.ConfigSetting;
|
|
|
|
|
var bot = GlobalConfig.BotContext;
|
|
|
|
|
var textEntities = chain.Where(o => o is TextEntity).ToList();
|
|
|
|
|
List<TextEntity> convertList = textEntities.Cast<TextEntity>().ToList().Where(o => o.Text.Contains("道友的个人悬赏令") || o.Text.Contains("天机悬赏令")).ToList();
|
|
|
|
|
|
|
|
|
|
string msg = "";
|
|
|
|
|
List<(int Id, decimal Price)> prices = new();
|
|
|
|
|
foreach (var want in wantedTasks)
|
|
|
|
|
foreach (var item in convertList)
|
|
|
|
|
{
|
|
|
|
|
List<WantedTaskInfo> wantedTasks = new();
|
|
|
|
|
if (item.Text.Contains("个人悬赏令"))
|
|
|
|
|
{
|
|
|
|
|
wantedTasks = await SingleWanted(item.Text);
|
|
|
|
|
}
|
|
|
|
|
else if (item.Text.Contains("天机悬赏令"))
|
|
|
|
|
{
|
|
|
|
|
wantedTasks = await SpecialWanted(item.Text);
|
|
|
|
|
}
|
|
|
|
|
if (wantedTasks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
msg += $"✨悬赏令 {want.Id} 奖励:{want.ExtraReward.Item}\r\n";
|
|
|
|
|
msg += $"🎁修为:{Utils.FormatNumberToChineseUnit(want.BaseReward)}\r\n";
|
|
|
|
|
var goodsInfo = RedisHelper.Client.HGet<GoodsInfo>(RedisPrefix.GoodsKey, want.ExtraReward.Item);
|
|
|
|
|
if (goodsInfo is not null)
|
|
|
|
|
var systemConfig = GlobalConfig.ConfigSetting;
|
|
|
|
|
var bot = GlobalConfig.BotContext;
|
|
|
|
|
|
|
|
|
|
string msg = "";
|
|
|
|
|
List<(int Id, decimal Price)> prices = new();
|
|
|
|
|
foreach (var want in wantedTasks)
|
|
|
|
|
{
|
|
|
|
|
msg += $"💵坊市价格:{goodsInfo.ShowPriceDesc}\r\n";
|
|
|
|
|
msg += $"✨悬赏令 {want.Id} 奖励:{want.ExtraReward.Item}\r\n";
|
|
|
|
|
msg += $"🎁修为:{Utils.FormatNumberToChineseUnit(want.BaseReward)}\r\n";
|
|
|
|
|
var goodsInfo = RedisHelper.Client.HGet<GoodsInfo>(RedisPrefix.GoodsKey, want.ExtraReward.Item);
|
|
|
|
|
if (goodsInfo is not null)
|
|
|
|
|
{
|
|
|
|
|
msg += $"💵坊市价格:{goodsInfo.ShowPriceDesc}\r\n";
|
|
|
|
|
|
|
|
|
|
prices.Add((want.Id, goodsInfo.Price));
|
|
|
|
|
prices.Add((want.Id, goodsInfo.Price));
|
|
|
|
|
}
|
|
|
|
|
//msg += $"炼金价格:\r\n";
|
|
|
|
|
msg += $"\r\n";
|
|
|
|
|
}
|
|
|
|
|
//msg += $"炼金价格:\r\n";
|
|
|
|
|
msg += $"\r\n";
|
|
|
|
|
}
|
|
|
|
|
var maxWanted = wantedTasks.MaxBy(o => o.BaseReward);
|
|
|
|
|
var maxWanted = wantedTasks.MaxBy(o => o.BaseReward);
|
|
|
|
|
|
|
|
|
|
msg += "━━━━━━━━━━━━━━━\r\n";
|
|
|
|
|
msg += $"✨最高修为:悬赏令 {maxWanted.Id} ({Utils.FormatNumberToChineseUnit(maxWanted.BaseReward)})\r\n";
|
|
|
|
|
if (prices.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var maxPrice = prices.MaxBy(o => o.Price);
|
|
|
|
|
msg += $"💰最高价格:悬赏令 {maxPrice.Id} ({Utils.FormatNumberToChineseUnit(maxPrice.Price)})";
|
|
|
|
|
msg += "━━━━━━━━━━━━━━━\r\n";
|
|
|
|
|
msg += $"✨最高修为:悬赏令 {maxWanted.Id} ({Utils.FormatNumberToChineseUnit(maxWanted.BaseReward)})\r\n";
|
|
|
|
|
if (prices.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var maxPrice = prices.MaxBy(o => o.Price);
|
|
|
|
|
msg += $"💰最高价格:悬赏令 {maxPrice.Id} ({Utils.FormatNumberToChineseUnit(maxPrice.Price)})";
|
|
|
|
|
}
|
|
|
|
|
await bot.SendMsg((uint)systemConfig.GroupQQ, msg);
|
|
|
|
|
}
|
|
|
|
|
await bot.SendMsg((uint)systemConfig.GroupQQ, msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logs.Write($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 悬赏令 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}");
|
|
|
|
|
}
|
|
|
|
|
return await Task.FromResult(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|