feat: 添加自动任务群监听触发验证码
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using Furion.Logging;
|
||||
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
||||
|
||||
namespace NapCatRobotClient.Service.Group.TextProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动做任务群触发验证消息给指定的QQ提示
|
||||
/// </summary>
|
||||
public class VerifyMsgProcess
|
||||
{
|
||||
/// <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 xx = json["user_id"]?.ToString();
|
||||
if (xx != App.Configuration["QQConfig:XiaoXiaoRobotQQ"])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string groupName = json["group_name"]?.ToString();
|
||||
List<string> text = ["请先验证", "请验证", "深色文字"];
|
||||
if (text.Any(message.Contains))
|
||||
{
|
||||
PrivateSendMessageRequest request = new()
|
||||
{
|
||||
UserId = App.Configuration["QQConfig:SendMsgQQ"],
|
||||
Message = new()
|
||||
{
|
||||
new MessageItem()
|
||||
{
|
||||
Type = "text",
|
||||
Data = new()
|
||||
{
|
||||
Text = $"{DateTime.Now}\r\n触发小小验证消息\r\n群昵称:{groupName}\r\n群号:{groupId}"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
await RobotAPI.SendPrivateText(request);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($@"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 自动修炼群触发验证消息 发生异常,异常信息:{ex.Message},异常堆栈:{ex.StackTrace}", true);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user