private void Client_ReceiveMsg(object sender, TEventArgs <List <AddMsg> > e) { foreach (var item in e.Result) { switch (item.MsgType) { case MsgType.MM_DATA_TEXT: if (contactDict.Keys.Contains(item.FromUserName)) { if (item.FromUserName.StartsWith("@@")) { //群消息,内容格式为[群内username];<br/>[content],例如Content=@ffda8da3471b87ff22a6a542c5581a6efd1b883698db082e529e8e877bef79b6:<br/>哈哈 string[] content = item.Content.Split(new string[] { ":<br/>" }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine(contactDict[item.FromUserName].NickName + ":" + contactDict[item.FromUserName].MemberDict[content[0]].NickName + ":" + content[1]); } else { Console.WriteLine(contactDict[item.FromUserName].NickName + ":" + item.Content); } } else { //不包含(一般为群)则需要我们主动拉取信息 weChatHelper.GetBatchGetContactAsync(item.FromUserName); } //自动回复 if (item.Content == "666666") { weChatHelper.SendMsgAsync("双击666!", item.FromUserName); } break; case MsgType.MM_DATA_HTML: break; case MsgType.MM_DATA_IMG: break; case MsgType.MM_DATA_PRIVATEMSG_TEXT: break; case MsgType.MM_DATA_PRIVATEMSG_HTML: break; case MsgType.MM_DATA_PRIVATEMSG_IMG: break; case MsgType.MM_DATA_VOICEMSG: break; case MsgType.MM_DATA_PUSHMAIL: break; case MsgType.MM_DATA_QMSG: break; case MsgType.MM_DATA_VERIFYMSG: //自动加好友,日限额80个左右,请勿超限额多次调用,有封号风险 //weChatHelper.VerifyUser(item.RecommendInfo); break; case MsgType.MM_DATA_PUSHSYSTEMMSG: break; case MsgType.MM_DATA_QQLIXIANMSG_IMG: break; case MsgType.MM_DATA_POSSIBLEFRIEND_MSG: break; case MsgType.MM_DATA_SHARECARD: break; case MsgType.MM_DATA_VIDEO: break; case MsgType.MM_DATA_VIDEO_IPHONE_EXPORT: break; case MsgType.MM_DATA_EMOJI: break; case MsgType.MM_DATA_LOCATION: break; case MsgType.MM_DATA_APPMSG: break; case MsgType.MM_DATA_VOIPMSG: break; case MsgType.MM_DATA_STATUSNOTIFY: switch (item.StatusNotifyCode) { case StatusNotifyCode.StatusNotifyCode_READED: break; case StatusNotifyCode.StatusNotifyCode_ENTER_SESSION: break; case StatusNotifyCode.StatusNotifyCode_INITED: break; case StatusNotifyCode.StatusNotifyCode_SYNC_CONV: //初始化的时候第一次sync会返回最近聊天的列表 weChatHelper.GetBatchGetContactAsync(item.StatusNotifyUserName); break; case StatusNotifyCode.StatusNotifyCode_QUIT_SESSION: break; default: break; } break; case MsgType.MM_DATA_VOIPNOTIFY: break; case MsgType.MM_DATA_VOIPINVITE: break; case MsgType.MM_DATA_MICROVIDEO: break; case MsgType.MM_DATA_SYSNOTICE: break; case MsgType.MM_DATA_SYS: //系统消息提示,例如完成好友验证通过,建群等等,提示消息“以已经通过了***的朋友验证请求,现在可以开始聊天了”、“加入了群聊” //不在字典,说明是新增,我们就主动拉取加入联系人字典 if (!contactDict.Keys.Contains(item.FromUserName)) { weChatHelper.GetBatchGetContactAsync(item.FromUserName); } break; case MsgType.MM_DATA_RECALLED: break; default: break; } } }