public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage) { var responseMessage = RequestMessage.CreateResponseMessage <ResponseMessageText>(); responseMessage.Content = "文字信息"; return(responseMessage); }
/// <summary> /// 根据当前的RequestMessage创建指定类型的ResponseMessage /// </summary> /// <typeparam name="TR">基于ResponseMessageBase的响应消息类型</typeparam> /// <returns></returns> protected TR CreateResponseMessage <TR>() where TR : ResponseMessageBase { if (RequestMessage == null) { return(null); } return(RequestMessage.CreateResponseMessage <TR>()); }
/// <summary> /// 根据当前的RequestMessage创建指定类型的ResponseMessage /// </summary> /// <typeparam name="TR">基于ResponseMessageBase的响应消息类型</typeparam> /// <returns></returns> public TR CreateResponseMessage <TR>() where TR : WorkResponseMessageBase { if (RequestMessage == null) { return(null); } return(RequestMessage.CreateResponseMessage <TR>()); }
//public abstract TR CreateResponseMessage<TR>() where TR : ResponseMessageBase; /// <summary> /// 根据当前的 RequestMessage 创建指定类型(RT)的 ResponseMessage /// </summary> /// <typeparam name="TR"></typeparam> /// <returns></returns> public virtual TR CreateResponseMessage <TR>() where TR : ResponseMessageBase { if (RequestMessage == null) { return(null); } return(RequestMessage.CreateResponseMessage <TR>(this.MessageEntityEnlightener)); }
public override void OnExecuting() { var storageModel = CurrentMessageContext.StorageData as StorageModel; if (storageModel != null && storageModel.IsInCmd) { storageModel.CmdCount++; if (storageModel.CmdCount >= 20) { var responseMessageText = RequestMessage.CreateResponseMessage <ResponseMessageText>(); responseMessageText.Content = "CmdCount已经大于等于2!"; ResponseMessage = responseMessageText; base.CancelExcute = true; } } base.OnExecuting(); }
/// <summary> /// 处理请求消息之前,统一处理事件 /// 此处的业务逻辑处理:根据用户的WeixinOpenId提示,提醒用户操作 /// 处理敏感词 /// </summary> public override void OnExecuting() { if (CurrentMessageContext.StorageData is StorageModel storageModel && storageModel.IsInCmd) { storageModel.CmdCount++; //接收到第5条消息的时候 提示重复 if (storageModel.CmdCount >= 5) { //使用全局的RequestMessage 和 ResponseMessage var responseMessageText = RequestMessage.CreateResponseMessage <ResponseMessageText>(); responseMessageText.Content = WeixinOpenId + " 您已经发送超过5条消息,请您10分钟以后再试"; ResponseMessage = responseMessageText; //取消后续的关键字匹配执行 CancelExcute = true; } } //继续执行 base.OnExecuting(); }