前言
监听CGroupMgr 在移除成员调用的方法
[KNHook hookClass:@"CGroupMgr"];
Nov 3 17:20:06 iPhone WeChat[5545] <Warning>: KNHooklog :-(c)DeleteGroupMember:withMemberList:scene:(have 3 value)
return:0
value1:__NSCFString-->5565276344@chatroom
value2:__NSArrayI-->(
z929118967
)
value3:__NSCFNumber-->0
object:<CGroupMgr: 0x1702b5b0>
##########################################
具体代码
- (void)MessageReturn:(unsigned int)arg1 MessageInfo:(NSDictionary *)info Event:(unsigned int)arg3 {
%orig;
NSLog(@"info:%@",info);
CMessageWrap *wrap = [info objectForKey:@"18"];
if (arg1 == 227) {
NSDate *now = [NSDate date];
NSTimeInterval nowSecond = now.timeIntervalSince1970;
if (nowSecond - wrap.m_uiCreateTime > 60) { // 若是1分钟前的消息,则不进行处理。
return;
}
CContactMgr *contactMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("CContactMgr")];
CContact *contact = [contactMgr getContactByName:wrap.m_nsFromUsr];
if(wrap.m_uiMessageType == 1) { // 收到文本消息
if (contact.m_uiFriendScene == 0 && ![contact isChatroom]) {
// 该消息为公众号
return;
}
if (![contact isChatroom]) { // 是否为群聊
// [self autoReplyWithMessageWrap:wrap]; // 自动回复个人消息
} else {
[self removeMemberWithMessageWrap:wrap]; // 自动踢人
// [self autoReplyChatRoomWithMessageWrap:wrap]; // 自动回复群消息
}
} else if(wrap.m_uiMessageType == 10000) { // 收到群通知,eg:群邀请了好友;删除了好友。
CContact *selfContact = [contactMgr getSelfContact];
if([selfContact.m_nsUsrName isEqualToString:contact.m_nsOwner]) { // 只有自己创建的群,才发送群欢迎语
// [self welcomeJoinChatRoomWithMessageWrap:wrap];
}
}
} else if (arg1 == 332) { // 收到添加好友消息
// [self addAutoVerifyWithMessageInfo:info];
}
}
%new
- (void)removeMemberWithMessageWrap:(CMessageWrap *)wrap {
// BOOL chatRoomSensitiveEnable = [[TKRobotConfig sharedConfig] chatRoomSensitiveEnable];
// if (!chatRoomSensitiveEnable) {
// return;
// }
CGroupMgr *groupMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("CGroupMgr")];
NSString *content = MSHookIvar<id>(wrap, "m_nsLastDisplayContent");
// NSMutableArray *array = [[TKRobotConfig sharedConfig] chatRoomSensitiveArray];
// [array enumerateObjectsUsingBlock:^(NSString *text, NSUInteger idx, BOOL * _Nonnull stop) {
// if([content isEqualToString:text]) {
[groupMgr DeleteGroupMember:wrap.m_nsFromUsr withMemberList:@[wrap.m_nsRealChatUsr] scene:3074516140857229312];
// }
// }];
}
添加成员
Nov 3 17:32:07 iPhone kernel[0] <Notice>: AppleARMPMUCharger: limiting USB input current to 400 mA (measured 497 mA)
Nov 3 17:33:58 iPhone WeChat[5579] <Warning>: KNHooklog :-(void)onServiceInit(have 0 value)
return:(null)
object:<CGroupMgr: 0x195f1850>
##########################################
Nov 3 17:33:58 iPhone WeChat[5579] <Warning>: KNHooklog :-(void)initDB:withLock:(have 2 value)
return:(null)
value1:CMMDB--><CMMDB: 0x193bdd60>
value2:NSRecursiveLock--><NSRecursiveLock: 0x193bd940>{locked = NO, thread = 0x0, recursion count = 0, name = nil}
object:<CGroupMgr: 0x195f1850>
##########################################
Nov 3 17:33:58 iPhone WeChat[5579] <Warning>: KNHooklog :-(c)AddGroupMember:withMemberList:withDesp:(have 3 value)
return:0
value1:__NSCFString-->5565276344@chatroom
value2:__NSArrayM-->(
"{m_nsMemberName=z929118967, m_uiMemberStatus=0, m_nsNickName=(null)}"
)
value3:(null)-->(null)
object:<CGroupMgr: 0x195f1850>
##########################################
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。