|
|
|
@ -25,11 +25,49 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string groupMsg = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "text"
|
|
|
|
string groupMsg = JArray.Parse(json["message"].ToString()).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();
|
|
|
|
&& !string.IsNullOrWhiteSpace(o["data"]["text"].ToString()) && (o["data"]["text"].ToString().Contains("道友的灵田还不能收取") || o["data"]["text"].ToString().Contains("道友本次采集成果") || o["data"]["text"].ToString().Contains("道友成功收获药材")))?["data"]?["text"]?.ToString();
|
|
|
|
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
|
|
|
if (string.IsNullOrWhiteSpace(groupMsg)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
List<GoodsInfo> goods = new();
|
|
|
|
List<GoodsInfo> goods = new();
|
|
|
|
if (groupMsg.Contains("道友本次采集成果"))
|
|
|
|
if (groupMsg.Contains("道友的灵田还不能收取"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
double ts = ConvertLastTime(groupMsg);
|
|
|
|
|
|
|
|
if (ts > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ts += 0.01;
|
|
|
|
|
|
|
|
var atData = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "at");
|
|
|
|
|
|
|
|
if (atData is not null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string at = atData["data"]["qq"].ToString();
|
|
|
|
|
|
|
|
ScheduleNextNotify(groupId, at, ts);
|
|
|
|
|
|
|
|
GroupSendMessageRequest request = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GroupId = groupId,
|
|
|
|
|
|
|
|
Message = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new MessageItem()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Type = "text",
|
|
|
|
|
|
|
|
Data = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = $"灵田结算预计在 【{DateTime.Now.AddHours(ts):yyyy-MM-dd HH:mm:ss}】 提醒您收取"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
new MessageItem()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Type = "at",
|
|
|
|
|
|
|
|
Data = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QQ = at
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
await RobotAPI.SendGroupText(request);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (groupMsg.Contains("道友本次采集成果"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
goods = await NewCmd(groupMsg);
|
|
|
|
goods = await NewCmd(groupMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -91,7 +129,7 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
|
|
|
var atData = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "at");
|
|
|
|
var atData = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "at");
|
|
|
|
if (atData is not null)
|
|
|
|
if (atData is not null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ScheduleNextNotify(groupId, atData["data"]["qq"].ToString());
|
|
|
|
ScheduleNextNotify(groupId, atData["data"]["qq"].ToString(), 47.01);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -104,6 +142,17 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
|
|
|
return await Task.FromResult(true);
|
|
|
|
return await Task.FromResult(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static double ConvertLastTime(string text)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Match match = Regex.Match(text, @"([\d\.]+)\s*小时");
|
|
|
|
|
|
|
|
double hours = 0;
|
|
|
|
|
|
|
|
if (match.Success)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
hours = double.Parse(match.Groups[1].Value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return hours;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static async Task<List<GoodsInfo>> OldCmd(string message)
|
|
|
|
private static async Task<List<GoodsInfo>> OldCmd(string message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<GoodsInfo> goodsInfos = new();
|
|
|
|
List<GoodsInfo> goodsInfos = new();
|
|
|
|
@ -134,41 +183,19 @@ namespace NapCatRobotClient.Service.Group.TextProcess
|
|
|
|
return await Task.FromResult(goodsInfos);
|
|
|
|
return await Task.FromResult(goodsInfos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void ScheduleNextNotify(string groupId, string userId)
|
|
|
|
private static void ScheduleNextNotify(string groupId, string userId, double hours)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TimeSpan delay = TimeSpan.FromHours(47.01);
|
|
|
|
DateTime now = DateTime.Now.AddHours(hours);
|
|
|
|
|
|
|
|
TimeSpan delay = TimeSpan.FromHours(hours + 0.09);
|
|
|
|
Log.Information($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} {userId} 触发下次灵田结算通知 ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = Task.Run(async () =>
|
|
|
|
Log.Information($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} {userId} 触发下次灵田结算通知 结算时间:{now} ");
|
|
|
|
{
|
|
|
|
|
|
|
|
await Task.Delay(delay);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GroupSendMessageRequest request = new()
|
|
|
|
RedisHelper.Client.Set($"{RedisPrefix.LingTianKey}{groupId}:{userId}", new TaskDetailInfo()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
GroupId = groupId,
|
|
|
|
GroupId = groupId,
|
|
|
|
Message = new()
|
|
|
|
UserId = userId,
|
|
|
|
{
|
|
|
|
TriggerTime = now
|
|
|
|
new MessageItem()
|
|
|
|
}, delay);
|
|
|
|
{
|
|
|
|
|
|
|
|
Type = "text",
|
|
|
|
|
|
|
|
Data = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = $"【灵田结算通知】\r\n该结算奖励了!"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
new MessageItem()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Type = "at",
|
|
|
|
|
|
|
|
Data = new()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QQ = userId
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
await RobotAPI.SendGroupText(request);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|