/// <summary>消息通知 /// </summary> /// <param name="msg"></param> /// <param name="userID_To"></param> /// <returns></returns> public virtual bool NotifyMsg(dynamic msg, string userID_To = "@*测试群", typeMsg typeMsg = typeMsg.TEXT, typeMsger typeMsger = typeMsger.wx) { if (msg + "" != null) { var pMsg = this.getMsg(msg, userID_To, false, typeMsg, typeMsger); if (pMsg != null) { MsgerHelper.Msger.SendMsg(pMsg, typeMsger); } } return(false); }
/// <summary>返回消息 /// </summary> /// <param name="text"></param> /// <param name="msgSrc"></param> /// <param name="typeMsg"></param> /// <returns></returns> public virtual Msg _ReturnMsg(string text, Msg msgSrc, typeMsg typeMsg, string msgTag = "") { string userID_To = msgSrc.UserName_src; typeMsger typeMsger = msgSrc.usrPlat; //修正消息 bool isGroup = msgSrc.IsUserGroup; string usrGroup = msgSrc.GetNameGroup(); string usrName = msgSrc.GetNameUser(); if (_Permission.Check_Permission_SysUsr(usrName, msgSrc.usrPlat.ToString()) || !this._Permission.Check_Permission_SingleSet(usrGroup, usrName, msgSrc.usrPlat.ToString())) { //查询用户信息--系统管理员屏蔽 userID_To = "filehelper"; //非独立设置调整为发送Helper isGroup = false; //修正消息内容,现实群组信息 string strTag = string.IsNullOrEmpty(msgTag) ? _Title : msgTag; if (msgSrc.IsUserGroup) { string strMsg_Group = string.Format("{0}:〖{1}〗\n", strTag, msgSrc.GetNameGroup()); text = strMsg_Group + text; } else { string strMsg_Group = string.Format("{0}:『{1}』\n", strTag, msgSrc.GetNameUser()); text = strMsg_Group + text; } } else { //添加文件头 if (_hasTitle) { if (typeMsg == typeMsg.TEXT) { string strTag = string.IsNullOrEmpty(msgTag) ? _Title : msgTag; if (!strTag.Contains(":")) { strTag += ":"; } text = strTag + "\n" + text; } } } //生成消息 Msg pMsgR = this.getMsg(text, userID_To, isGroup, typeMsg, typeMsger, msgTag); return(pMsgR); }
/// <summary>消息通知 /// </summary> /// <param name="msg"></param> /// <param name="userID_To"></param> /// <returns></returns> public virtual bool NotifyMsg(dynamic msg, Msg msgSrc, string msgTag = "", typeMsg typeMsg = typeMsg.NONE) { if (msg + "" != null) { Msg pMsg = _ReturnMsg(msg, msgSrc, msgTag, typeMsg); if (pMsg != null) { return(MsgerHelper.Msger.SendMsg(pMsg, pMsg.usrPlat)); } //else // ConsoleHelper.Debug(true, msg); } return(false); }
/// <summary>返回消息 /// </summary> /// <param name="text"></param> /// <param name="msgSrc"></param> /// <returns></returns> public virtual Msg _ReturnMsg(string text, Msg msgSrc, string msgTag = "", typeMsg typeMsg = typeMsg.NONE) { return(_ReturnMsg(text, msgSrc, typeMsg == typeMsg.NONE ? msgSrc.msgType : typeMsg, msgTag)); }
//提取返回消息 protected internal virtual Msger.Msg getMsg(string msg, string userID_To = "@*测试群", bool isUsrGroup = false, typeMsg typeMsg = typeMsg.TEXT, typeMsger typeMsger = typeMsger.wx, string msgTag = "") { if (msg + "" == "") { return(null); } if (userID_To + "" == "") { return(null); } if (typeMsger == typeMsger.None) { return(null); } //组装消息 if (!isUsrGroup) { isUsrGroup = userID_To.Length > 2 && userID_To.Substring(0, 2) == "@*" ? true : isUsrGroup; } Msger.Msg pMsg = new Msger.Msg() { msgID = "", msg = msg + "", msgType = typeMsg == typeMsg.NOTE ? typeMsg.TEXT : typeMsg, msgLink = "", groupID = isUsrGroup ? userID_To : "", usrName = userID_To, usrNameNick = userID_To, usrPlat = typeMsger, UserName_src = _tag, msgTime = DateTime.Now, msgTag = msgTag, IsUserGroup = isUsrGroup, IsFromRobot = true, IsSend = true }; return(pMsg); }