auto reply plugin on wechat

// auto reply
%hook CMessageMgr
- (void)AsyncOnAddMsg:(NSString *)msg MsgWrap:(CMessageWrap *)wrap {
  %orig;
  if ([[wrap m_nsFromUsr] rangeOfString:@"@chatroom"].location == NSNotFound) {
    if (([wrap m_uiStatus] == 4 || [wrap m_uiStatus] == 3) && [wrap m_uiMessageType] == 1) {
      BOOL isOn = [[[WXSettingsInstance allSettings] objectForKey:kOpenAutoReply] boolValue];
      if (isOn) {
        NSString *sendMsg = [[WXSettingsInstance allSettings] objectForKey:kAutoReplyContent];

        WeixinContentLogicController *logicController = [objc_getClass("WeixinContentLogicController") new];
        CMessageWrap *newWrap = [logicController FormTextMsg:[wrap m_nsFromUsr] withText:sendMsg];

        CMessageMgr *globalMessageMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("CMessageMgr") class]];
        [globalMessageMgr AddMsg:[newWrap m_nsToUsr] MsgWrap:newWrap];
      }
    }
  }
}
%end

你可能感兴趣的:(auto reply plugin on wechat)