mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2026-07-28 22:14:33 +08:00
Fix #367
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#import "WeChatTweak.h"
|
||||
#import "NSString+WeChatTweak.h"
|
||||
#import "NSBundle+WeChatTweak.h"
|
||||
|
||||
@implementation NSObject (AntiRevoke)
|
||||
@@ -28,11 +27,12 @@ static void __attribute__((constructor)) tweak(void) {
|
||||
return [self tweak_FFToNameFavChatZZ:message sessionMsgList:sessionMsgList];
|
||||
}
|
||||
// Decode message
|
||||
NSString *session = [message.msgContent tweak_subStringFrom:@"<session>" to:@"</session>"];
|
||||
NSUInteger newMessageID = [message.msgContent tweak_subStringFrom:@"<newmsgid>" to:@"</newmsgid>"].longLongValue;
|
||||
NSString *replaceMessage = [message.msgContent tweak_subStringFrom:@"<replacemsg><![CDATA[" to:@"]]></replacemsg>"];
|
||||
NSDictionary *dictionary = [NSDictionary dictionaryWithXMLString:message.msgContent];
|
||||
NSString *session = dictionary[@"revokemsg"][@"session"];
|
||||
NSString *newMessageID = dictionary[@"revokemsg"][@"newmsgid"];
|
||||
NSString *replaceMessage = dictionary[@"revokemsg"][@"replacemsg"];
|
||||
// Get message data
|
||||
MessageData *messageData = ((id (*)(id, SEL, id, unsigned long long))objc_msgSend)(self, GetMsgDataSelector, session, newMessageID);
|
||||
MessageData *messageData = ((id (*)(id, SEL, id, unsigned long long))objc_msgSend)(self, GetMsgDataSelector, session, newMessageID.longLongValue);
|
||||
if (messageData.isSendFromSelf) {
|
||||
// Fallback to origin method
|
||||
[self tweak_FFToNameFavChatZZ:message sessionMsgList:sessionMsgList];
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// NSString+WeChatTweak.h
|
||||
// WeChatTweak
|
||||
//
|
||||
// Created by Sunnyyoung on 2017/8/12.
|
||||
// Copyright © 2017年 Sunnyyoung. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSString (WeChatTweak)
|
||||
|
||||
- (NSString *)tweak_subStringFrom:(NSString *)beginString to:(NSString *)endString;
|
||||
|
||||
@end
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// NSString+WeChatTweak.m
|
||||
// WeChatTweak
|
||||
//
|
||||
// Created by Sunnyyoung on 2017/8/12.
|
||||
// Copyright © 2017年 Sunnyyoung. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSString+WeChatTweak.h"
|
||||
|
||||
@implementation NSString (WeChatTweak)
|
||||
|
||||
- (NSString *)tweak_subStringFrom:(NSString *)beginString to:(NSString *)endString {
|
||||
NSRange begin = [self rangeOfString:beginString];
|
||||
if (begin.location == NSNotFound) {
|
||||
return nil;
|
||||
}
|
||||
NSRange end = [self rangeOfString:endString];
|
||||
if (end.location == NSNotFound) {
|
||||
return nil;
|
||||
}
|
||||
NSRange range = NSMakeRange(begin.location + begin.length, end.location - begin.location - begin.length);
|
||||
if (range.location == NSNotFound) {
|
||||
return nil;
|
||||
}
|
||||
return [self substringWithRange:range];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user