fix: 小小 药材价格查询 秘境通知修复
This commit is contained in:
@@ -24,7 +24,8 @@ namespace NapCatRobotClient.API.Controllers
|
||||
{
|
||||
using StreamReader reader = new(Request.Body);
|
||||
string body = await reader.ReadToEndAsync();
|
||||
//Log.Information($"接收到群消息:{body}");
|
||||
Log.Information($"接收到群消息:{body} \r\n");
|
||||
body = "{\"self_id\":3902582794,\"user_id\":3889001741,\"time\":1781882943,\"message_id\":650215683,\"message_seq\":650215683,\"real_id\":650215683,\"real_seq\":\"1698687\",\"message_type\":\"group\",\"sender\":{\"user_id\":3889001741,\"nickname\":\"小小\",\"card\":\"\",\"role\":\"member\"},\"raw_message\":\"[CQ:markdown,content=[](%7B%22version%22%3A2%7D)\\n道友的灵田还不能收取,下次收取时间为:44.77小时之后]道友的灵田还不能收取,下次收取时间为:44.77小时之后\",\"font\":14,\"sub_type\":\"normal\",\"message\":[{\"type\":\"markdown\",\"data\":{\"content\":\"[](%7B%22version%22%3A2%7D)\\n道友的灵田还不能收取,下次收取时间为:44.77小时之后\"}},{\"type\":\"text\",\"data\":{\"text\":\"道友的灵田还不能收取,下次收取时间为:44.77小时之后\"}}],\"message_format\":\"array\",\"post_type\":\"message\",\"group_id\":285855428,\"group_name\":\"??????颂我名者轮回得永生??????\"}";
|
||||
bool result = await _dispatcherService.ReceiveMessageAndProcess(body);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
|
||||
# 设置环境变量
|
||||
ENV TZ=Asia/Shanghai
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
ENTRYPOINT ["dotnet", "NapCatRobotClient.API.dll"]
|
||||
@@ -1,12 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>zh-CN</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NapCatRobotClient.Service\NapCatRobotClient.Service.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NapCatRobotClient.Service\NapCatRobotClient.Service.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
services:
|
||||
xx_napcat_bot_image:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: xx_napcat_bot
|
||||
environment:
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PORT=6379
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
ports:
|
||||
- "5000:5000"
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- redis-server_default
|
||||
|
||||
networks:
|
||||
redis-server_default:
|
||||
external: true
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
{
|
||||
JObject json = JObject.Parse(message);
|
||||
var messageArray = JArray.Parse(json["message"].ToString());
|
||||
string groupMsg = messageArray.FirstOrDefault(o => o["type"].ToString() == "text"
|
||||
string groupMsg = messageArray.LastOrDefault(o => o["type"].ToString() == "text"
|
||||
&& !string.IsNullOrWhiteSpace(o["data"]["text"].ToString()))?["data"]?["text"]?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||
|
||||
|
||||
+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,
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||
|
||||
List<GoodsInfo> goods = new();
|
||||
if (groupMsg.Contains("道友的灵田还不能收取")|| groupMsg.Contains("道友的灵田灵气未满"))
|
||||
if (groupMsg.Contains("道友的灵田还不能收取") || groupMsg.Contains("道友的灵田灵气未满"))
|
||||
{
|
||||
double ts = ConvertLastTime(groupMsg);
|
||||
if (ts > 0)
|
||||
|
||||
+6
-5
@@ -1,5 +1,6 @@
|
||||
using Furion.Logging;
|
||||
using System.Globalization;
|
||||
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
|
||||
|
||||
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
{
|
||||
@@ -24,11 +25,11 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
List<string> keywords = new() { "进入秘境", "道友已踏入", "道友已破界", "道友已遁入", "道友已降临" };
|
||||
|
||||
string groupMsg = messageArray
|
||||
.FirstOrDefault(o =>
|
||||
o["type"]?.ToString() == "text"
|
||||
&& !string.IsNullOrWhiteSpace(o["data"]?["text"]?.ToString())
|
||||
&& keywords.Any(k => o["data"]["text"].ToString().Contains(k))
|
||||
)?["data"]?["text"]?.ToString();
|
||||
.FirstOrDefault(o =>
|
||||
o["type"]?.ToString() == "text"
|
||||
&& !string.IsNullOrWhiteSpace(o["data"]?["text"]?.ToString())
|
||||
&& keywords.Any(k => o["data"]["text"].ToString().Contains(k))
|
||||
)?["data"]?["text"]?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
||||
|
||||
var minutes = ParseMinutes(groupMsg);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user