feat: 新功能
This commit is contained in:
@@ -14,6 +14,10 @@ namespace NapCatRobotClient.API.Controllers
|
|||||||
_dispatcherService = dispatcherService;
|
_dispatcherService = dispatcherService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ½ÓÊÕÏûÏ¢Èë¿Ú
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Post()
|
public async Task<IActionResult> Post()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,135 @@
|
|||||||
"SendApiUrl": "http://192.168.142.133:3000",
|
"SendApiUrl": "http://192.168.142.133:3000",
|
||||||
"AccessToken": "123456",
|
"AccessToken": "123456",
|
||||||
"RobotQQ": "3902582794",
|
"RobotQQ": "3902582794",
|
||||||
|
"XiaoXiaoRobotQQ": "3889001741",
|
||||||
"XiuXianGroupId": "705807264"
|
"XiuXianGroupId": "705807264"
|
||||||
|
},
|
||||||
|
"丹方": {
|
||||||
|
"灭神古丸": "配方主药三尾风叶1药引血菩提1辅药混元果1丹炉寒铁铸心炉\r\n配方主药冰灵焰草1药引诱妖草1辅药混元果1丹炉寒铁铸心炉",
|
||||||
|
"易筋丹": "配方主药三尾风叶1药引血菩提1辅药天剑笋1丹炉寒铁铸心炉\r\n配方主药冰灵焰草1药引诱妖草1辅药天剑笋1丹炉寒铁铸心炉",
|
||||||
|
"静禅魔丸": "配方主药八角玄冰草1药引芒焰果1辅药血玉竹1丹炉寒铁铸心炉\r\n配方主药奇茸通天菊1药引问道花1辅药血玉竹1丹炉寒铁铸心炉\r\n配方主药地心淬灵乳1药引宁心草1辅药血玉竹1丹炉寒铁铸心炉",
|
||||||
|
"化煞魔丸": "配方主药血莲精1药引血莲精1辅药石龙芮1丹炉寒铁铸心炉",
|
||||||
|
"养气丹": "配方主药血莲精1药引恒心草1辅药血莲精1丹炉寒铁铸心炉",
|
||||||
|
"素心真丸": "配方主药雪玉骨参1药引穿心莲1辅药伴妖草1丹炉寒铁铸心炉\r\n配方主药腐骨灵花1药引龙鳞果1辅药伴妖草1丹炉寒铁铸心炉",
|
||||||
|
"地仙玄丸": "配方主药檀芒九叶花1药引浩淼水藤1辅药狼桃1丹炉寒铁铸心炉\r\n配方主药坎水玄冰果1药引道蕴花1辅药狼桃1丹炉寒铁铸心炉",
|
||||||
|
"天尘丹": "配方主药地心淬灵乳1药引宁心草1辅药八角玄冰草1丹炉寒铁铸心炉",
|
||||||
|
"金仙造化丹": "配方主药离火梧桐芝7药引宁心草1辅药太乙碧莹花7丹炉寒铁铸心炉\r\n\r\n离火梧桐芝=尘磊岩麟果,药引=任意性平,太乙碧莹花=森檀木=炼心芝=重元换血草",
|
||||||
|
"创世丹": "配方主药离火梧桐芝5药引宁心草1辅药太乙碧莹花5丹炉寒铁铸心炉\r\n\r\n离火梧桐芝=尘磊岩麟果,药引=任意性平,太乙碧莹花=森檀木=炼心芝=重元换血草",
|
||||||
|
"太乙炼髓丹": "配方主药剑魄竹笋3药引鬼面花3辅药太乙碧莹花3丹炉寒铁铸心炉\r\n配方主药剑魄竹笋3药引炼心芝3辅药太乙碧莹花3丹炉寒铁铸心炉\r\n配方主药明心问道果3药引重元换血草3辅药太乙碧莹花3丹炉寒铁铸心炉\r\n配方主药明心问道果3药引梧桐木3辅药太乙碧莹花3丹炉寒铁铸心炉",
|
||||||
|
"混沌丹": "配方主药离火梧桐芝4药引宁心草1辅药太乙碧莹花4丹炉寒铁铸心炉",
|
||||||
|
"极品混沌丹": "配方主药离火梧桐芝5药引宁心草1辅药阴阳黄泉花9丹炉寒铁铸心炉\r\n\r\n离火梧桐芝=尘磊岩麟果,药引=任意性平,阴阳黄泉花=厉魂血珀",
|
||||||
|
"太上玄门丹": "配方主药剑魄竹笋1药引鬼面花1辅药太乙碧莹花1丹炉寒铁铸心炉\r\n配方主药剑魄竹笋1药引炼心芝1辅药太乙碧莹花1丹炉寒铁铸心炉\r\n配方主药明心问道果1药引重元换血草1辅药太乙碧莹花1丹炉寒铁铸心炉",
|
||||||
|
"金仙破厄丹": "配方主药剑魄竹笋2药引鬼面花2辅药太乙碧莹花2丹炉寒铁铸心炉\r\n配方主药剑魄竹笋2药引炼心芝2辅药太乙碧莹花2丹炉寒铁铸心炉",
|
||||||
|
"太清玉液丹": "配方主药尘磊岩麟果20药引宁心草1辅药地龙干20丹炉寒铁铸心炉\r\n配方主药剑魄竹笋20药引鬼面花20辅药地龙干20丹炉寒铁铸心炉\r\n配方主药剑魄竹笋20药引炼心芝20辅药地龙干20丹炉寒铁铸心炉\r\n配方主药明心问道果20药引重元换血草20辅药地龙干20丹炉寒铁铸心炉\r\n配方主药剑明心问道果20药引梧桐木20辅药地龙干20丹炉寒铁铸心炉\r\n\r\n辅药地龙干=龙须藤=鬼面花=梧桐木",
|
||||||
|
"菩提证道丹": "配方主药剑魄竹笋10药引鬼面花10辅药太乙碧莹花10丹炉寒铁铸心炉\r\n配方主药剑魄竹笋10药引炼心芝10辅药太乙碧莹花10丹炉寒铁铸心炉\r\n配方主药明心问道果10药引重元换血草10辅药太乙碧莹花10丹炉寒铁铸心炉\r\n配方主药明心问道果10药引梧桐木10辅药太乙碧莹花10丹炉寒铁铸心炉\r\n配方主药尘磊岩麟果10药引宁心草1辅药太乙碧莹花10丹炉寒铁铸心炉\r\n\r\n离火梧桐芝=尘磊岩麟果,药引=任意性平,太乙碧莹花=森檀木=炼心芝=重元换血草",
|
||||||
|
"大道归一丹": "配方主药剑魄竹笋8药引鬼面花8辅药太乙碧莹花8丹炉寒铁铸心炉\r\n配方主药剑魄竹笋8药引炼心芝8辅药太乙碧莹花8丹炉寒铁铸心炉\r\n配方主药明心问道果8药引重元换血草8辅药太乙碧莹花8丹炉寒铁铸心炉\r\n配方主药明心问道果8药引梧桐木8辅药太乙碧莹花8丹炉寒铁铸心炉\r\n\r\n辅药太乙碧莹花=森檀木=炼心芝=重元换血草",
|
||||||
|
"九天蕴仙丹": "配方主药剑魄竹笋6药引鬼面花6辅药太乙碧莹花6丹炉寒铁铸心炉\r\n配方主药剑魄竹笋6药引炼心芝6辅药太乙碧莹花6丹炉寒铁铸心炉\r\n配方主药明心问道果6药引重元换血草6辅药太乙碧莹花6丹炉寒铁铸心炉\r\n配方主药明心问道果6药引梧桐木6辅药太乙碧莹花6丹炉寒铁铸心炉\r\n\r\n辅药太乙碧莹花=森檀木=炼心芝=重元换血草",
|
||||||
|
"极品创世丹": "配方主药剑魄竹笋6药引鬼面花6辅药阴阳黄泉花11丹炉寒铁铸心炉\r\n配方主药剑魄竹笋6药引炼心芝6辅药阴阳黄泉花11丹炉寒铁铸心炉\r\n配方主药明心问道果6药引重元换血草6辅药阴阳黄泉花11丹炉寒铁铸心炉\r\n配方主药明心问道果6药引梧桐木6辅药阴阳黄泉花11丹炉寒铁铸心炉",
|
||||||
|
"渡劫仙丹": "配方主药离火梧桐芝9药引石龙芮4辅药森檀木9丹炉寒铁铸心炉"
|
||||||
|
},
|
||||||
|
"猜成语": {
|
||||||
|
"🚶🐎👀🌸": "走马观花",
|
||||||
|
"💧🏾🔥🥵": "水深火热",
|
||||||
|
"😞🌸😭👧🏻": "愁眉苦脸",
|
||||||
|
"🌬️🌶️⏏️🎤": "吹拉弹唱",
|
||||||
|
"🦩🧍🐔👨": "鹤立鸡群",
|
||||||
|
"🕸️👁️🐟🚢": "望眼欲穿",
|
||||||
|
"👩🎨🐍🦢🐾": "画蛇添足",
|
||||||
|
"🍃🚌👌🐲": "叶公好龙",
|
||||||
|
"🌸🍐🐯🥄": "花里胡哨",
|
||||||
|
"❤️🤔🍅🍊": "心想事成",
|
||||||
|
"🌪️🍼🌊🐳": "风平浪静",
|
||||||
|
"🍚👴⭕👦": "返老还童",
|
||||||
|
"🆘🧑📞😀": "助人为乐",
|
||||||
|
"🐊🐟🔪👨": "恶语伤人",
|
||||||
|
"🛀🏻😭❌💦": "欲哭无泪",
|
||||||
|
"🥃💧🚗💴": "杯水车薪",
|
||||||
|
"🍵🍚❌🤔": "茶饭不思",
|
||||||
|
"👨⛰️👨🌊": "人山人海",
|
||||||
|
"🤚🤖👨": "白手起家",
|
||||||
|
"🐷👫🐶👉": "猪朋狗友",
|
||||||
|
"7️⃣👆8️⃣👇": "七上八下",
|
||||||
|
"🔪⛏️🔥🌱": "刀耕火种",
|
||||||
|
"✉️🍅🥚🥚": "信誓旦旦",
|
||||||
|
"✍️🐍👇🦶": "画蛇添足",
|
||||||
|
"💩🈚💰🍐": "史无前例",
|
||||||
|
"🤤🍐🦁🔒": "流离失所",
|
||||||
|
"😔🐟🍂🦢": "沉鱼落雁",
|
||||||
|
"😄🍐🍱🔪": "笑里藏刀",
|
||||||
|
"👗🐉💃✋": "群龙无首",
|
||||||
|
"👗🐉🈚✋": "群龙无首",
|
||||||
|
"❤️💡👣📣": "心照不宣",
|
||||||
|
"🌫️🍐👀🌷": "雾里看花",
|
||||||
|
"⛰️🚪🌊": "山盟海誓",
|
||||||
|
"🍅🌊📞": "四海为家",
|
||||||
|
"🐓🐕🚁🌁": "鸡犬升天",
|
||||||
|
"🐺🚬4️⃣🛫": "狼烟四起",
|
||||||
|
"🦱😵👀🌀": "头晕眼花",
|
||||||
|
"🎹🧒1⃣🈴": "情投意合",
|
||||||
|
"🔫🌲💣🌧️": "枪林弹雨",
|
||||||
|
"🤨👀📠💑": "眉目传情",
|
||||||
|
"🈯🍃🤬🌳": "指桑骂槐",
|
||||||
|
"🎁👆🏻🕸️🚶": "礼尚往来",
|
||||||
|
"🐱🙅🉑👄": "妙不可言",
|
||||||
|
"🧑🏑☝🈯": "首屈一指",
|
||||||
|
"👍🗣🤝☯": "能说会道",
|
||||||
|
"📱💐🔗🪵": "移花接木",
|
||||||
|
"🗣🏋❤️🦒": "语重心长",
|
||||||
|
"😲🌥👋🌎": "惊天动地",
|
||||||
|
"🙅🏻♀️💪🦔🦶": "不吝赐教",
|
||||||
|
"🥶🌪️🦔": "寒风刺骨",
|
||||||
|
"😣🤍🐔🖐🏻": "痛心疾首",
|
||||||
|
"💐👍🌙⭕": "花好月圆",
|
||||||
|
"🐟🐝🍹💪": "渔翁之利",
|
||||||
|
"🐑🚶🐯👄": "羊入虎口",
|
||||||
|
"⛰🖐️🍊👨": "三五成群",
|
||||||
|
"👄🧱🐍🧍": "唇枪舌战",
|
||||||
|
"🖐👆🔆🐷": "掌上明珠",
|
||||||
|
"🌊🥀🪨😖": "海枯石烂",
|
||||||
|
"🕳️🏠🌺🕯": "洞房花烛",
|
||||||
|
"🌿🌑🌺🌕": "柳暗花明",
|
||||||
|
"🥃🍽️🐺📕": "杯盘狼藉",
|
||||||
|
"👺👹👻👾": "妖魔鬼怪",
|
||||||
|
"🈚💵🇿👶": "无价之宝",
|
||||||
|
"🥇🎍🚿🖐🏻": "金盆洗手",
|
||||||
|
"👶🍝👹❤️": "人面兽心",
|
||||||
|
"🎉🌥🏮🌎": "欢天喜地",
|
||||||
|
"🥴➕1️⃣💡": "罪加一等",
|
||||||
|
"🧑👼👫💩": "人神共愤",
|
||||||
|
"💑🔝🌹🔥": "喜上眉梢",
|
||||||
|
"🖐🌸👨🚪": "五花八门",
|
||||||
|
"🉐1️⃣🔭🧳": "得意忘形",
|
||||||
|
"🔪🛶⚽⚔": "刻舟求剑",
|
||||||
|
"🍽🚪👈☯": "旁门左道",
|
||||||
|
"🏔️🐛💧➖": "山重水复",
|
||||||
|
"🌪🌂🥂👨": "风雨交加",
|
||||||
|
"🧑📣🍲♨": "人声鼎沸",
|
||||||
|
"🐏📱🎵🧣": "阳奉阴违",
|
||||||
|
"🍊🏠🍐🍃": "成家立业",
|
||||||
|
"🏴❤️👟💪": "齐心协力",
|
||||||
|
"☀️⬇️🍉🏔": "日落西山",
|
||||||
|
"❄️🌧️⭐️🌪️": "血雨腥风",
|
||||||
|
"📖💰💃🚗": "学富五车",
|
||||||
|
"👄👄📷📠": "口口相传",
|
||||||
|
"🐻🈶🍊🎋": "胸有成竹",
|
||||||
|
"🐟🎵🌀🌾": "余音绕梁",
|
||||||
|
"1️⃣🕸️🈚️💰": "一往无前",
|
||||||
|
"📢🍜🔔🐉": "八面玲珑",
|
||||||
|
"🐍🐔🆘👨": "舍己救人",
|
||||||
|
"👂👀": "耳目一新",
|
||||||
|
"🍊🐠⬇️🐦": "沉鱼落雁",
|
||||||
|
"🤍🐳🥩💃": "心惊肉跳",
|
||||||
|
"👚💉🚀☃️": "一针见血",
|
||||||
|
"💍🌸🧶🛕": "借花献佛",
|
||||||
|
"🍊👗🎀✔️": "成群结队",
|
||||||
|
"☝️️👏🏻🐔🈴": "一拍即合",
|
||||||
|
"🍏♣🎋🐎": "青梅竹马",
|
||||||
|
"🚬👦👂👀": "掩人耳目",
|
||||||
|
"🌾💊😣👄": "良药苦口",
|
||||||
|
"🚴🐅😞👇": "骑虎难下",
|
||||||
|
"❌👀😍🤔": "不堪设想",
|
||||||
|
"🍺🍀": "九死一生",
|
||||||
|
"😲🏹🇿🐦": "惊弓之鸟",
|
||||||
|
"🐓✈️🥚🤛": "鸡飞蛋打"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace NapCatRobotClient.Core.RobotAPI
|
|||||||
.WithHeader("Content-Type", "application/json;charset=utf-8")
|
.WithHeader("Content-Type", "application/json;charset=utf-8")
|
||||||
.PostStringAsync(parameters)
|
.PostStringAsync(parameters)
|
||||||
.ReceiveString();
|
.ReceiveString();
|
||||||
Console.WriteLine($"{DateTime.Now} 请求地址:{url} 请求结果:{response}");
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,15 @@ namespace NapCatRobotClient.Service.Group.Service
|
|||||||
|
|
||||||
_ = InertOrUpdateGoodsInfoProcess.ProcessGroupRequest(groupId, message);
|
_ = InertOrUpdateGoodsInfoProcess.ProcessGroupRequest(groupId, message);
|
||||||
|
|
||||||
_= LingTianProcess.ProcessGroupRequest(groupId, message);
|
_ = LingTianProcess.ProcessGroupRequest(groupId, message);
|
||||||
|
|
||||||
|
_ = ChineseIdiomsProcess.ProcessGroupRequest(groupId, message);
|
||||||
|
|
||||||
|
_ = GoodsUpShopProcess.ProcessGroupRequest(groupId, message);
|
||||||
|
|
||||||
|
_ = MiJingNotifyProcess.ProcessGroupRequest(groupId, message);
|
||||||
|
|
||||||
|
_ = ImmortalElixirProcess.ProcessGroupRequest(groupId, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using Furion.Logging;
|
||||||
|
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||||
|
|
||||||
|
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 猜成语
|
||||||
|
/// </summary>
|
||||||
|
public class ChineseIdiomsProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 处理群消息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<bool> ProcessGroupRequest(string groupId, string message)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JObject json = JObject.Parse(message);
|
||||||
|
string groupMsg = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "text"
|
||||||
|
&& !string.IsNullOrWhiteSpace(o["data"]["text"].ToString()) && (o["data"]["text"].ToString().Contains("要道友看表情猜成语")))?["data"]?["text"]?.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||||
|
|
||||||
|
string pattern = @"题目:(.+)";
|
||||||
|
Match match = Regex.Match(groupMsg, pattern);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
string emojiString = match.Groups[1].Value.Trim();
|
||||||
|
Dictionary<string, string> dict = App.GetConfig<Dictionary<string, string>>("猜成语");
|
||||||
|
if (dict?.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in dict)
|
||||||
|
{
|
||||||
|
if (emojiString.Contains(item.Key))
|
||||||
|
{
|
||||||
|
GroupSendMessageRequest request = new()
|
||||||
|
{
|
||||||
|
GroupId = groupId,
|
||||||
|
Message = new()
|
||||||
|
{
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "reply",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
Id = json["message_id"].ToString()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "text",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
Text = item.Value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await RobotAPI.SendGroupText(request);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 猜成语 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}", true);
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
using Furion.Logging;
|
||||||
|
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||||
|
|
||||||
|
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 坊市上架命令
|
||||||
|
/// </summary>
|
||||||
|
public class GoodsUpShopProcess
|
||||||
|
{
|
||||||
|
public static async Task<bool> ProcessGroupRequest(string groupId, string message)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JObject json = JObject.Parse(message);
|
||||||
|
var messageArray = JArray.Parse(json["message"].ToString());
|
||||||
|
string groupMsg = messageArray.FirstOrDefault(o => o["type"].ToString() == "text"
|
||||||
|
&& !string.IsNullOrWhiteSpace(o["data"]["text"].ToString()))?["data"]?["text"]?.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||||
|
|
||||||
|
// 小小药材背包
|
||||||
|
List<string> keyWord = new() { "拥有数量", "坊市数据" };
|
||||||
|
if (keyWord.All(k => groupMsg.Contains(k)))
|
||||||
|
{
|
||||||
|
RedisHelper.Client.Set(json["message_id"].ToString(), groupMsg, 60 * 10);
|
||||||
|
}
|
||||||
|
// 用户查询上架
|
||||||
|
else if (groupMsg.Contains("查价格") || groupMsg.Contains("查上架") && messageArray.Any(o => o["type"].ToString() == "reply"))
|
||||||
|
{
|
||||||
|
string replyId = messageArray.FirstOrDefault(o => o["type"].ToString() == "reply")["data"]["id"].ToString();
|
||||||
|
var goodsStr = RedisHelper.Client.Get(replyId);
|
||||||
|
if (string.IsNullOrEmpty(goodsStr) is false)
|
||||||
|
{
|
||||||
|
bool upCmd = groupMsg.Contains("-f");
|
||||||
|
|
||||||
|
_ = Herbal(groupId, goodsStr, upCmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GroupSendMessageRequest request = new()
|
||||||
|
{
|
||||||
|
GroupId = groupId,
|
||||||
|
Message = new()
|
||||||
|
{
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "text",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
Text = "没有查询到缓存,请重新艾特小小查药材背包"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await RobotAPI.SendGroupText(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 坊市上架命令 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<bool> Herbal(string groupId, string text, bool upCmd)
|
||||||
|
{
|
||||||
|
List<GoodsInfo> results = [];
|
||||||
|
var lines = text.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
if (line.StartsWith("品级:"))
|
||||||
|
{
|
||||||
|
_ = line.Substring("品级:".Length).Trim();
|
||||||
|
}
|
||||||
|
else if (line.StartsWith("名字:"))
|
||||||
|
{
|
||||||
|
var name = line.Substring("名字:".Length).Trim();
|
||||||
|
// 找到下一行的数量
|
||||||
|
var index = Array.IndexOf(lines, line);
|
||||||
|
if (index + 1 < lines.Length && lines[index + 1].StartsWith("拥有数量:"))
|
||||||
|
{
|
||||||
|
var quantityLine = lines[index + 1];
|
||||||
|
var match = Regex.Match(quantityLine, @"拥有数量:(\d+)");
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
var quantity = match.Groups[1].Value;
|
||||||
|
results.Add(new() { Name = name, Num = Convert.ToInt32(quantity) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string msg = "";
|
||||||
|
decimal totalPrice = 0;
|
||||||
|
decimal fee = 0;
|
||||||
|
// 打印结果
|
||||||
|
foreach (var item in results)
|
||||||
|
{
|
||||||
|
var current = RedisHelper.Client.HGet<GoodsInfo>(RedisPrefix.GoodsKey, item.Name);
|
||||||
|
if (current is not null)
|
||||||
|
{
|
||||||
|
int num = item.Num.Value > 10 ? 10 : item.Num.Value;
|
||||||
|
decimal nicePrice = current.Price - 100000;
|
||||||
|
totalPrice += Convert.ToDecimal(nicePrice * num);
|
||||||
|
|
||||||
|
fee += Math.Round(Utils.CalculateFee(nicePrice) * num, 0);
|
||||||
|
|
||||||
|
if (upCmd)
|
||||||
|
{
|
||||||
|
msg += $"确认坊市上架{item.Name} {(int)current.Price - 100000} {num}|";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg += $"确认坊市上架{item.Name} {(int)current.Price - 100000} {num}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(msg) is false)
|
||||||
|
{
|
||||||
|
if (!upCmd)
|
||||||
|
{
|
||||||
|
msg += "\r\n";
|
||||||
|
msg += "使用前请先@小小查看坊市药材,过完一遍以获取最新价格\r\n当前价格为坊市价格-10w\r\n";
|
||||||
|
msg += $"总价值约:{Utils.FormatNumberToChineseUnit(totalPrice)}\r\n";
|
||||||
|
msg += $"手续费约:{Utils.FormatNumberToChineseUnit(fee)}\r\n";
|
||||||
|
msg += $"到账约:{Utils.FormatNumberToChineseUnit(totalPrice - fee)}";
|
||||||
|
}
|
||||||
|
if (msg[^1] == '|') msg = msg[..^1];
|
||||||
|
|
||||||
|
GroupSendMessageRequest request = new()
|
||||||
|
{
|
||||||
|
GroupId = groupId,
|
||||||
|
Message = new()
|
||||||
|
{
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "text",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
Text = msg
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await RobotAPI.SendGroupText(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
using Furion.Logging;
|
||||||
|
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||||
|
|
||||||
|
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查丹方
|
||||||
|
/// </summary>
|
||||||
|
public class ImmortalElixirProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 处理群消息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<bool> ProcessGroupRequest(string groupId, string message)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JObject json = JObject.Parse(message);
|
||||||
|
var messageArray = JArray.Parse(json["message"].ToString());
|
||||||
|
string groupMsg = messageArray.FirstOrDefault(o => o["type"].ToString() == "text"
|
||||||
|
&& !string.IsNullOrWhiteSpace(o["data"]["text"].ToString())
|
||||||
|
&& o["data"]["text"].ToString().Contains("查丹方")
|
||||||
|
)?["data"]?["text"]?.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||||
|
|
||||||
|
var rbotQ = messageArray.FirstOrDefault(o => o["type"].ToString() == "at")?["data"]?["qq"]?.ToString();
|
||||||
|
|
||||||
|
// 判断是否@了机器人
|
||||||
|
if (rbotQ == App.Configuration["QQConfig:RobotQQ"])
|
||||||
|
{
|
||||||
|
// 提取物品名称
|
||||||
|
var goodsName = groupMsg
|
||||||
|
.Split(' ', StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.FirstOrDefault(word => word != "查丹方")
|
||||||
|
?.Replace("查丹方", "")?.Trim();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(goodsName))
|
||||||
|
{
|
||||||
|
Dictionary<string, string> dict = App.GetConfig<Dictionary<string, string>>("丹方");
|
||||||
|
if (dict?.Count > 0)
|
||||||
|
{
|
||||||
|
dict.TryGetValue(goodsName, out string doc);
|
||||||
|
if (string.IsNullOrWhiteSpace(doc) is false)
|
||||||
|
{
|
||||||
|
GroupSendMessageRequest request = new()
|
||||||
|
{
|
||||||
|
GroupId = groupId,
|
||||||
|
Message = new()
|
||||||
|
{
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "text",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
Text = doc
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await RobotAPI.SendGroupText(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 查丹方命令 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}", true);
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,9 @@ using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
|||||||
|
|
||||||
namespace NapCatRobotClient.Service.Group.TextProcess
|
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 灵田结算
|
||||||
|
/// </summary>
|
||||||
public class LingTianProcess
|
public class LingTianProcess
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
using Furion.Logging;
|
||||||
|
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 秘境通知
|
||||||
|
/// </summary>
|
||||||
|
public class MiJingNotifyProcess
|
||||||
|
{
|
||||||
|
public static async Task<bool> ProcessGroupRequest(string groupId, string message)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JObject json = JObject.Parse(message);
|
||||||
|
var messageArray = JArray.Parse(json["message"].ToString());
|
||||||
|
string groupMsg = messageArray.FirstOrDefault(o => o["type"].ToString() == "text"
|
||||||
|
&& !string.IsNullOrWhiteSpace(o["data"]["text"].ToString())
|
||||||
|
&& (o["data"]["text"].ToString().Contains("进入秘境:") || o["data"]["text"].ToString().Contains("道友已踏入:"))
|
||||||
|
)?["data"]?["text"]?.ToString();
|
||||||
|
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||||
|
|
||||||
|
var minutes = ParseMinutes(groupMsg);
|
||||||
|
if (minutes > 0)
|
||||||
|
{
|
||||||
|
var atData = messageArray.FirstOrDefault(o => o["type"].ToString() == "at");
|
||||||
|
if (atData is not null)
|
||||||
|
{
|
||||||
|
ScheduleReminder(groupId, atData["data"]["qq"].ToString(), minutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 秘境结束通知 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}", true);
|
||||||
|
}
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ScheduleReminder(string groupId, string userId, double minutes)
|
||||||
|
{
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
|
TimeSpan delay = TimeSpan.FromMinutes(minutes);
|
||||||
|
|
||||||
|
Log.Information($@"{now:yyyy-MM-dd HH:mm:ss} {userId} 触发秘境通知 {minutes}分钟 结束时间: {now.AddMinutes(minutes):yyyy-MM-dd HH:mm:ss}");
|
||||||
|
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(delay);
|
||||||
|
GroupSendMessageRequest request = new()
|
||||||
|
{
|
||||||
|
GroupId = groupId,
|
||||||
|
Message = new()
|
||||||
|
{
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "text",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
Text = $"【秘境结算通知】\r\n探索已完成,该结算奖励了!({minutes} 分钟)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new MessageItem()
|
||||||
|
{
|
||||||
|
Type = "at",
|
||||||
|
Data = new()
|
||||||
|
{
|
||||||
|
QQ = userId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await RobotAPI.SendGroupText(request);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double ParseMinutes(string content)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(content)) return 0;
|
||||||
|
|
||||||
|
var match = Regex.Match(content, @"(花费时间|探索耗时)[::]\s*(\d+(?:\.\d+)?)", RegexOptions.Compiled);
|
||||||
|
if (!match.Success)
|
||||||
|
{
|
||||||
|
match = Regex.Match(content, @"(\d+(?:\.\d+)?)", RegexOptions.Compiled);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
if (double.TryParse(match.Groups[2].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out double val))
|
||||||
|
{
|
||||||
|
return (double)val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user