/// <summary> /// 执行过滤器 /// </summary> /// <returns></returns> private static MiddlewareParameter Execute(MiddlewareParameter middlareResult) { //全局开始过滤器 GlobalPreFilters.ForEach(filter => filter(middlareResult)); //处理文本消息 if (middlareResult.Input.RequestBaseModel.MsgType == Configurations.Current.MessageType.Text) { var textReq = middlareResult.Input.GetRequestModel <TextRequest>(); TextFilters.Execute(textReq, middlareResult); } //处理图片消息 if (middlareResult.Input.RequestBaseModel.MsgType == Configurations.Current.MessageType.Image) { var imageReq = middlareResult.Input.GetRequestModel <ImageRequest>(); ImageFilters.Execute(imageReq, middlareResult); } //位置信息 if (middlareResult.Input.RequestBaseModel.MsgType == Configurations.Current.MessageType.Location) { var locationReq = middlareResult.Input.GetRequestModel <LocationRequest>(); LocationFilters.Execute(locationReq, middlareResult); } //事件 if (middlareResult.Input.RequestBaseModel.MsgType == Configurations.Current.MessageType.Event) { var eb = middlareResult.Input.GetRequestModel <EventBase>(); //普通过滤器 EventFileters.Execute(eb, middlareResult); if (eb.Event == Configurations.Current.EventType.Click) { //单击菜单事件 var clickReq = middlareResult.Input.GetRequestModel <ClickMenuRequest>(); ClickFilters.Execute(clickReq, middlareResult); } if (eb.Event == Configurations.Current.EventType.Scan) { //扫描二维码事件 var scanReq = middlareResult.Input.GetRequestModel <ScanQrRequest>(); ScanQrFilters.Execute(scanReq, middlareResult); } if (eb.Event == Configurations.Current.EventType.Location) { //位置事件 var positionReq = middlareResult.Input.GetRequestModel <PositionRequest>(); PositionFilter.Execute(positionReq, middlareResult); } } //执行 语音识别结果 过滤器 if (middlareResult.Input.RequestBaseModel.MsgType == Configurations.Current.MessageType.Voice) { var voiceReq = middlareResult.Input.GetRequestModel <VoiceRequest>(); VoiceFilters.Execute(voiceReq, middlareResult); } //全局结束过滤器 GlobalEndFilters.ForEach(filter => filter(middlareResult)); return(middlareResult); }