using Furion.Logging; using NapCatRobotClient.Core.RobotAPI.Dto.Request; namespace NapCatRobotClient.Service.Group.TextProcess { /// /// 自动做任务群触发验证消息给指定的QQ提示 /// public class VerifyMsgProcess { /// /// 处理群消息 /// /// /// public static async Task 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 text = ["请先验证", "请验证", "深色文字"]; if (text.Any(message.Contains)) { var atData = JArray.Parse(json["message"].ToString()).FirstOrDefault(o => o["type"].ToString() == "at"); List 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); } } }