% hook CMessageMgr - (void)onRevokeMsg:(CMessageWrap * )arg1 { if (HZWechatConfig.preventRevoke) { NSString * msgContent = arg1.m_nsContent; NSString * (^parseParam)(NSString * , NSString * ,NSString * ) = ^NSString * (NSString * content, NSString * paramBegin,NSString * paramEnd) { NSUInteger startIndex = [content rangeOfString:paramBegin].location + paramBegin.length; NSUInteger endIndex = [content rangeOfString:paramEnd].location; NSRange range = NSMakeRange(startIndex, endIndex - startIndex); return [content substringWithRange: range ]; }; NSString * session = parseParam(msgContent, @ "" , @ "" ); NSString * newmsgid = parseParam(msgContent, @ "" , @ "" ); NSString * fromUsrName = parseParam(msgContent, @ ", @ "撤回了一条消息" ); CMessageWrap * revokemsg = [ self GetMsg:session n64SvrID:[newmsgid integerValue]]; CContactMgr * contactMgr = [[objc_getClass( "MMServiceCenter" ) defaultCenter] getService:objc_getClass( "CContactMgr" )]; CContact * selfContact = [contactMgr getSelfContact]; NSString * newMsgContent = @""; if ([revokemsg.m_nsFromUsr isEqualToString:selfContact.m_nsUsrName]) { if (revokemsg.m_uiMessageType = = 1 ) { / / 判断是否为文本消息 newMsgContent = [NSString stringWithFormat:@ "拦截到你撤回了一条消息:\n %@" ,revokemsg.m_nsContent]; } else { newMsgContent = @ "拦截到你撤回一条消息" ; } } else { if (revokemsg.m_uiMessageType = = 1 ) { newMsgContent = [NSString stringWithFormat:@ "拦截到一条 %@撤回消息:\n %@" ,fromUsrName, revokemsg.m_nsContent]; } else { newMsgContent = [NSString stringWithFormat:@ "拦截到一条 %@撤回消息" ,fromUsrName]; } } CMessageWrap * newWrap = ({ CMessageWrap * msg = [[ % c(CMessageWrap) alloc] initWithMsgType: 0x2710 ]; [msg setM_nsFromUsr:revokemsg.m_nsFromUsr]; [msg setM_nsToUsr:revokemsg.m_nsToUsr]; [msg setM_uiStatus: 0x4 ]; [msg setM_nsContent:newMsgContent]; [msg setM_uiCreateTime:[arg1 m_uiCreateTime]]; msg; }); [ self AddLocalMsg:session MsgWrap:newWrap fixTime: 0x1 NewMsgArriveNotify: 0x0 ]; return ; } % orig; } % end |