feat: 新增灵田 秘境结算持久化
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Furion.Logging;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||
|
||||
namespace NapCatRobotClient.Service.BackGround
|
||||
{
|
||||
/// <summary>
|
||||
/// 灵田结算通知
|
||||
/// </summary>
|
||||
public class LingTianBackGroundWorker : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
string[] keys = RedisHelper.Client.Keys($"{RedisPrefix.LingTianKey}*");
|
||||
|
||||
foreach (string key in keys)
|
||||
{
|
||||
string json = RedisHelper.Client.Get(key);
|
||||
if (string.IsNullOrEmpty(json)) continue;
|
||||
|
||||
TaskDetailInfo task = JsonConvert.DeserializeObject<TaskDetailInfo>(json);
|
||||
if (task.TriggerTime <= DateTime.Now)
|
||||
{
|
||||
GroupSendMessageRequest request = new()
|
||||
{
|
||||
GroupId = task.GroupId,
|
||||
Message = new()
|
||||
{
|
||||
new MessageItem()
|
||||
{
|
||||
Type = "text",
|
||||
Data = new()
|
||||
{
|
||||
Text = $"【灵田结算通知】\r\n该结算奖励了!"
|
||||
}
|
||||
},
|
||||
new MessageItem()
|
||||
{
|
||||
Type = "at",
|
||||
Data = new()
|
||||
{
|
||||
QQ = task.UserId
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_ = RobotAPI.SendGroupText(request);
|
||||
|
||||
RedisHelper.Client.Del(key);
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Furion.Logging;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||
|
||||
namespace NapCatRobotClient.Service.BackGround
|
||||
{
|
||||
/// <summary>
|
||||
/// 秘境结算通知
|
||||
/// </summary>
|
||||
public class MijingBackGroundWorker : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
string[] keys = RedisHelper.Client.Keys($"{RedisPrefix.MiJingKey}*");
|
||||
|
||||
foreach (string key in keys)
|
||||
{
|
||||
string json = RedisHelper.Client.Get(key);
|
||||
if (string.IsNullOrEmpty(json)) continue;
|
||||
|
||||
TaskDetailInfo task = JsonConvert.DeserializeObject<TaskDetailInfo>(json);
|
||||
if (task.TriggerTime <= DateTime.Now)
|
||||
{
|
||||
GroupSendMessageRequest request = new ()
|
||||
{
|
||||
GroupId = task.GroupId,
|
||||
Message =
|
||||
[
|
||||
new MessageItem
|
||||
{
|
||||
Type = "text",
|
||||
Data = new() { Text = $"【秘境结算通知】\r\n探索已完成,该结算奖励了!({task.Minutes} 分钟)" }
|
||||
},
|
||||
new MessageItem
|
||||
{
|
||||
Type = "at",
|
||||
Data = new() { QQ = task.UserId }
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
_ = RobotAPI.SendGroupText(request);
|
||||
|
||||
RedisHelper.Client.Del(key);
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user