feat: 命令异常拦截
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Lagrange.Core.Message;
|
||||
using Lagrange.Core.Message.Entity;
|
||||
using RoBot.Start.LogConfig;
|
||||
using RoBot.Start.Service.Impl;
|
||||
|
||||
namespace RoBot.Start.Cmd
|
||||
@@ -10,6 +11,8 @@ namespace RoBot.Start.Cmd
|
||||
public class InertOrUpdateGoodsCmd
|
||||
{
|
||||
public static async Task<bool> Execute(MessageChain chain)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var item in chain)
|
||||
{
|
||||
@@ -26,6 +29,12 @@ namespace RoBot.Start.Cmd
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 保存或更新物品价格 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}");
|
||||
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Lagrange.Core.Message.Entity;
|
||||
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;
|
||||
|
||||
@@ -14,6 +15,8 @@ namespace RoBot.Start.Cmd
|
||||
public class QueryGoodsInfoPriceCmd
|
||||
{
|
||||
public static async Task<bool> Execute(MessageChain chain)
|
||||
{
|
||||
try
|
||||
{
|
||||
var systemConfig = GlobalConfig.ConfigSetting;
|
||||
var bot = GlobalConfig.BotContext;
|
||||
@@ -57,6 +60,11 @@ namespace RoBot.Start.Cmd
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 查看物品信息命令 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}");
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using RoBot.Core;
|
||||
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;
|
||||
|
||||
@@ -17,6 +18,8 @@ namespace RoBot.Start.Cmd
|
||||
{
|
||||
|
||||
public static async Task<bool> Execute(MessageChain chain)
|
||||
{
|
||||
try
|
||||
{
|
||||
var systemConfig = GlobalConfig.ConfigSetting;
|
||||
if (chain.Count == 3 &&
|
||||
@@ -47,7 +50,12 @@ namespace RoBot.Start.Cmd
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 坊市上架命令 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}");
|
||||
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -17,6 +18,9 @@ namespace RoBot.Start.Cmd
|
||||
public class WantedPriceCmd
|
||||
{
|
||||
public static async Task<bool> Execute(MessageChain chain)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
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();
|
||||
@@ -65,8 +69,11 @@ namespace RoBot.Start.Cmd
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user