You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
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))
|
|
{
|
|
var atData = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "at");
|
|
List<string> sendMsg =
|
|
[
|
|
DateTime.Now.ToString(),
|
|
"【触发小小验证码消息】",
|
|
$"群昵称:{groupName}",
|
|
$"群号:{groupId}",
|
|
$"QQ号:{atData?["data"]?["qq"]}"
|
|
];
|
|
PrivateSendMessageRequest request = new()
|
|
{
|
|
UserId = App.Configuration["QQConfig:SendMsgQQ"],
|
|
Message = new()
|
|
{
|
|
new MessageItem()
|
|
{
|
|
Type = "text",
|
|
Data = new()
|
|
{
|
|
Text = string.Join("\r\n",sendMsg)
|
|
}
|
|
}
|
|
}
|
|
};
|
|
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);
|
|
}
|
|
|
|
}
|
|
}
|