發紅包

前言

tweak 經過剪切板和lua 腳本進行通訊服務器

標題文字 ##利用cy 獲取對應的處理方法

#"<WCRedEnvelopesMakeRedEnvelopesViewController: 0x18c3c200>"

點擊 塞錢進紅包微信

OnMakeWCRedEnvelopesButtonClick

利用hopper查看僞代碼

建立訂單數據
WCRedEnvelopesControlData setM_dicPrepayRequestOrderInfo:app

totalAmount

正文

發紅包界面lua

%hook WCRedEnvelopesMakeRedEnvelopesViewController

步驟A1 --點擊「發紅包」按鈕

//------------------------------執行發送紅包任務--------------------------------

%hook NewMainFrameViewController
/*打開來聊天對話框 開始執行發送紅包的動做A1*/
- (void)openMessageContentView:(id)arg1 
              startSendMessage:(BOOL)arg2 
                    msgWrapToAdd:(id)arg3 
                      animated:(BOOL)arg4 
         jumpToFirstUnreadNode:(BOOL)arg5 
                      indexPath:(id)arg6
{


    %log();
    %orig;
    

    if (hongbaoQueue.count <= 0) 
    {
        /* code */
        return;
    }

    UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];    
    [pasteboard setString:@"A1"];
}

%end

步驟A2

*發紅包界面*/
%hook WCRedEnvelopesMakeRedEnvelopesViewController
/*A2 步驟: 設置發送紅包金額*/
- (void)viewDidLoad
{
    %log();
    %orig;

    if (hongbaoQueue.count <= 0) 
    {
        /* code */
        return;
    }
    
    NSMutableDictionary *dict = hongbaoQueue[0];
    NSString *moneyNum = dict[@"moneyNum"];
    
    NSString *string = [NSString stringWithFormat:@"%@:%@",@"A2",NON(moneyNum)];
    UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];    
    [pasteboard setString:string];
    NSLog(@"pasteboard:%@",pasteboard.string);
}

通知服務器紅包發送成功:調用服務器接口

//點擊塞錢進紅包按鈕
- (void)OnMakeWCRedEnvelopesButtonClick
{
    %orig;

    // //設置紅包返點發送成功

    // NSLog(@"設置紅包返點發送成功:%@",response);

}

A3,返回回到主界面

/*A3,從WCRedEnvelopesMakeRedEnvelopesViewController 發紅包界面返回回到主界面   */
- (void)viewWillDisappear:(BOOL)arg1
{
    %orig;
    UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:@"A3"];
    NSLog(@"pasteboard:%@",pasteboard.string);
}

//執行發送紅包的任務 組裝發送信息並 執行A1 步驟

%new 
- (void)doSendHongBaoTask
{
    NSMutableDictionary *dict = hongbaoQueue[0];
    NSString *wx_Id = dict[@"sendTo"];
    NSLog(@"發送紅包對象:%@", wx_Id);
    id MainFrameLogic = [objc_getClass("MainFrameLogicController") new];
    id NewMainFrame = [objc_getClass("NewMainFrameViewController") new];

    CContactMgr *contactManager = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("CContactMgr") class]];
    CContact *contact = [contactManager getContactByName:wx_Id];
            
    //頁面跳轉
    id data = objc_msgSend(MainFrameLogic, @selector(getSessionInfoByContact:), contact);
    objc_msgSend(NewMainFrame, @selector(openMessageContentView:startSendMessage:msgWrapToAdd:animated:jumpToFirstUnreadNode:indexPath:), data, NO, NULL, YES, NO, NULL);
}

關鍵代碼

調用新增的方法,採用運行時
請求接口的例子code

id WCRedEnvelopesLogicMgr = [objc_getClass("WCRedEnvelopesLogicMgr") new];
        NSData *res = objc_msgSend(WCRedEnvelopesLogicMgr, @selector(ApiPost:Param:),@"http://=1.0.0", param);
        NSDictionary *response = [NSJSONSerialization JSONObjectWithData:res options:0 error:NULL];

發送消息的例子orm

NSString *fromUser = [objc_getClass("SettingUtil") getLocalUsrName:0];

            objc_msgSend(gMessageMgr, @selector(sendTextMessageFromUser:toUser:content:), fromUser, toUser, content);

知足發紅包的條件,給用戶發送紅包

重點部分,獲取發送數據的時間、和執行任務的時間對象

只有當微信啓動的時候才進行數據查詢和發送接口

Nov  1 16:27:27 iPhone WeChat[1530] <Notice>: [RedRobert] Tweak.xm:34 DEBUG: -[<CMessageMgr: 0x16bc9d60> init]

或者能夠定時發送隊列

NSString *time =  [TaokeHttpTool getFormatCurrDatetime];
    NSLog(@"time:%@",time);
    if (![time hasPrefix:@"1623"]/* condition */)
    {
        return;

        /* code */
    }
%hook BaseMsgContentViewController


清除數據,執行下一個紅包任務
==============

 (void)onBackButtonClicked:(id)arg1
{
    %log();
    %orig;

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:@""];
    NSLog(@"pasteboard:%@", pasteboard.string);

    if (hongbaoQueue.count > 0) {
        [hongbaoQueue removeObjectAtIndex:0];
        NSLog(@"刪除成功");
    }

    //啓動發紅包任務隊列
    if (hongbaoQueue.count > 0) {
        id WCRedEnvelopesLogicMgr = [objc_getClass("WCRedEnvelopesLogicMgr") new];
        objc_msgSend(WCRedEnvelopesLogicMgr, @selector(doSendHongBaoTask));
        NSLog(@"啓動發紅包任務隊列");
    }
}

%end

/查看輸入的密碼/

%hook TenpayPasswordCtrl

- (void)numberKeyBoardClicked:(id)arg1{


    // %log();
    return %orig;
}
/*查看輸入的密碼*/
- (void)appendPsw:(id)arg1{
        %log();
    return %orig;

}
%end

獲取用戶座標

--test
--獲取用戶點擊的座標 
         -- x,y = catchTouchPoint();

        -- sysLog("tcatchTouchPoint"..x..","..y);



        --end test
x,y = catchTouchPoint();--等待用戶輸入
相關文章
相關標籤/搜索