某唄極速版,簡易紅包輔助的代碼實現

github下載項目源碼,內含app包。git


主要代碼

//紅包消息Model
%hook _TtC3Jst29JST_RedpacketMessageViewModel

- (id)initWithSLCtMessage:(id)arg1
{
    %log;
    redpacketMessage = %orig;
    
    long long senderId = [redpacketMessage getSenderId];
    
    SLCfGiveRedPacketMessageContentImpl * content = [redpacketMessage getContent];// <SLCfGiveRedPacketMessageContentImpl: 0x17445e240>
    
    NSLog(@"do--initWithSLCtMessage--content= (%@)",content);
    
    NSString * tradeNumber = [content getTradeNumber];
    
    long amount = (long)[content getAmount];
    
    NSString * text = [content getText];
    
    NSLog(@"do--initWithSLCtMessage--(%@, %ld, %@, %@, %@, senderId:%lld)",tradeNumber,amount,text,[content getRedPacketType],[content isCollected]?@"已搶":@"沒搶",senderId);
    
    [self autoGrabRedpacket:redpacketMessage];
    
    return redpacketMessage;
}

%new
-(void)autoGrabRedpacket:(_TtC3Jst29JST_RedpacketMessageViewModel *)redpacket
{
    
    long long senderId = [redpacket getSenderId];
    
    SLCfGiveRedPacketMessageContentImpl * content = [redpacket getContent];// <SLCfGiveRedPacketMessageContentImpl: 0x17445e240>
    
    NSLog(@"do--autoGrabRedpacket--content= (%@)",content);
    
    NSString * tradeNumber = [content getTradeNumber];
    long amount = (long)[content getAmount];
    NSString * text = [content getText];
    
    NSLog(@"do--autoGrabRedpacket--(%@, %ld, %@, %@, %@, senderId:%lld)",tradeNumber,amount,text,[content getRedPacketType],[content isCollected]?@"已搶":@"沒搶", senderId);
    
    SLCtRedPacketChannel * channel = [%c(SLCtRedPacketChannel) GENERAL];
    
    agent = [%c(SLCtRedPacketAgent) getInstance];
    
    // arg0
    // arg1 是 紅包id
    // arg2 是 senderId
    [agent sendCollectRedPacketRequestWithSLHttpCallback:nil withNSString:tradeNumber withLong:senderId withSLCtRedPacketChannel:channel];
    NSLog(@"do--autoGrabRedpacket--finish");
}

%end
複製代碼

  • 每當羣內有紅包消息,會觸發 _TtC3Jst29JST_RedpacketMessageViewModel 類的 initWithSLCtMessage 方法,初始化一個紅包信息model。
  • redpacketMessage 是一個全局變量,表明紅包信息model,用於保存當前的紅包信息。從 redpacketMessage 中能拿到屬性 senderId 和 tradeNumber,這兩個是搶紅包的必備參數。
  • SLCtRedPacketAgent * agent; 是一個紅包代理,用於處理紅包的邏輯,這裏只須要調用 "[agent sendCollectRedPacketRequestWithSLHttpCallback:nil withNSString:tradeNumber withLong:senderId withSLCtRedPacketChannel:channel]" 可實現秒搶紅包。

使用

  • 直接下載工程,手機鏈接電腦,使用Xcode在手機運行工程便可。
  • 進入羣聊頁面,自動秒搶當前羣內紅包。

關注公衆號:逆向APP

相關文章
相關標籤/搜索