2023-07-27 09:20:00 +08:00
|
|
|
//
|
|
|
|
|
// TUITool+TUIPatch.m
|
|
|
|
|
// Youth
|
|
|
|
|
//
|
|
|
|
|
// Created by mambaxie on 2022/2/21.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "TUITool+TUIPatch.h"
|
|
|
|
|
#import <JRSwizzle.h>
|
|
|
|
|
#import "NSObject+BKAssociatedObjects.h"
|
|
|
|
|
#import "PYAppService.h"
|
|
|
|
|
|
|
|
|
|
@implementation TUITool (TUIPatch)
|
|
|
|
|
|
|
|
|
|
+ (void)load {
|
|
|
|
|
NSError *error;
|
|
|
|
|
[self jr_swizzleClassMethod:@selector(patch_makeToast:) withClassMethod:@selector(makeToast:) error:&error];
|
|
|
|
|
if (error) {
|
|
|
|
|
NSLog(@"patch TUI error: %@", error);
|
|
|
|
|
}
|
|
|
|
|
[self jr_swizzleClassMethod:@selector(patch_makeToastError:msg:) withClassMethod:@selector(makeToastError:msg:) error:&error];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSArray *)ignoreTipsPrefixes {
|
|
|
|
|
static NSArray *prefixes = nil;
|
|
|
|
|
if (!prefixes) {
|
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
|
prefixes = @[
|
|
|
|
|
@"You were removed from the group",
|
|
|
|
|
@"您已被踢出"
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return prefixes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (void)patch_makeToast:(NSString *)str {
|
|
|
|
|
BOOL shouldIgnore = NO;
|
|
|
|
|
for (NSString *prefix in [self ignoreTipsPrefixes]) {
|
|
|
|
|
if ([str hasPrefix:prefix]) {
|
|
|
|
|
shouldIgnore = YES;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (shouldIgnore) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self patch_makeToast:str];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (void)patch_makeToastError:(NSInteger)error msg:(NSString *)msg {
|
|
|
|
|
|
|
|
|
|
if (error >= 120001 && error <= 120099) {
|
|
|
|
|
if (error == 120010) {
|
|
|
|
|
[PYAppService showVipAlertWithPath:nil title:nil msg:msg source:@"block_chat_wx"];
|
|
|
|
|
}else if(error == 120011){
|
|
|
|
|
[PYAppService showVipAlertWithPath:nil title:nil msg:msg source:@"block_chat_se"];
|
|
|
|
|
}else{
|
|
|
|
|
[PYAppService showVipAlertWithPath:nil title:nil msg:msg source:@"block_chat_unknow"];
|
|
|
|
|
}
|
|
|
|
|
}else if (error >= 120100 && error <= 120199) {
|
|
|
|
|
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
|
|
|
|
|
config.title = @"聊天提示";
|
2023-07-27 18:25:18 +08:00
|
|
|
if ([msg containsString:@"需要互关/VIP才能聊天才能发送图片和语音"]) {
|
|
|
|
|
config.message = [msg stringByReplacingOccurrencesOfString:@"互关/" withString:@""];
|
2023-07-31 09:33:00 +08:00
|
|
|
config.otherTitle = @"去开通会员";
|
|
|
|
|
config.otherHandler = ^(MTAlertButton *button) {
|
|
|
|
|
[PYAppService showVipVC:@"vip_page"];
|
|
|
|
|
};
|
2023-07-27 18:25:18 +08:00
|
|
|
} else {
|
|
|
|
|
config.message = msg;
|
2023-07-31 09:33:00 +08:00
|
|
|
config.otherTitle = @"OK";
|
2023-07-27 18:25:18 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-31 09:33:00 +08:00
|
|
|
|
2023-07-27 09:20:00 +08:00
|
|
|
}];
|
|
|
|
|
}else{
|
|
|
|
|
[self patch_makeToastError:error msg:msg];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|