Skip to content

Commit

Permalink
Merge pull request #23 from lanjuzi/master
Browse files Browse the repository at this point in the history
Update ==> 增加游戏作弊功能 by @lanjuzi
  • Loading branch information
TKkk-iOSer committed Oct 22, 2017
2 parents 6ba96bf + 3c8e635 commit 15ef772
Show file tree
Hide file tree
Showing 27 changed files with 1,924 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -9,6 +9,8 @@ include $(THEOS)/makefiles/common.mk

TWEAK_NAME = robot
robot_FILES = $(wildcard src/*.m) src/Tweak.xm
robot_CFLAGS = -fobjc-arc
robot_OBJCFLAGS = -Wno-error

include $(THEOS_MAKE_PATH)/tweak.mk

Expand Down
Binary file added Others/ScreenShots/Setting-03.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Others/ScreenShots/Setting-cheat.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Others/ScreenShots/dice.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Others/ScreenShots/jsb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Others/autoInsertDylib.sh
Expand Up @@ -47,7 +47,7 @@ app_path="${shell_path}/extracted/Payload/${APPLICATION}"
# cp -R ${app_path} ./

# rm -rf ~/Desktop/temp/extracted/Payload/$APPLICATION/*Watch*

cp "${shell_path}/popup_close_btn.png" ${app_path}
cp ${dylib_path} ${libsubstrate_path} ${app_path}

# echo "删除" ${APPLICATION##*/} "中 watch 相关文件"
Expand Down
Binary file added Others/popup_close_btn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions README.md
@@ -1,9 +1,12 @@
## WeChatPlugin-iOS

微信小助手-iOS版 v1.0.0
微信小助手-iOS版 v1.0.0

<img src="./Others/ScreenShots/WeChatPlugin.jpg" width="500">
> 增加了游戏(石头剪刀布、骰子)作弊功能
使用 [zhPopupController](https://github.com/snail-z/zhPopupController) 来显示作弊内容,并使用 `zhPopupController` 的 Example 模板

<img src="./Others/ScreenShots/WeChatPlugin.jpg" width="500"> <img src="./Others/ScreenShots/Setting-cheat.jpg" width="500">

**mac OS 版请戳→_[WeChatPlugin-MacOS](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS)**

Expand All @@ -19,6 +22,7 @@
- [x] 敏感词自动踢人
- [x] 入群欢迎语
- [x] 群消息自动回复
- [x] 游戏作弊(石头剪刀布、骰子)

**统一设置群公告、敏感词自动踢人、入群欢迎语 仅对自己创建的群有效**

Expand Down Expand Up @@ -52,9 +56,9 @@

#### 2. 生成注入的app文件

* 可直接通过百度云下载
链接: https://pan.baidu.com/s/1c120oww 密码: 95bx(微信版本为6.5.16)
链接: https://pan.baidu.com/s/1bL1oei 密码: grbi (微信版本 6.5.17)
* 可直接通过百度云下载
链接: https://pan.baidu.com/s/1c120oww 密码: 95bx(微信版本为6.5.16)
链接: https://pan.baidu.com/s/1bL1oei 密码: grbi (微信版本 6.5.17)

* 若想修改源码,生成新的dylib,可在修改之后执行`make`,之后拷贝生成的dylib(~~路径为`./theos/obj/debug/robot.dylib`~~),最后执行 `./Others/autoInsertDylib.sh ipa文件路径 dylib文件路径` 即可获得注入dylib的app文件。

Expand Down Expand Up @@ -95,5 +99,5 @@
---

#### 听说你想请我喝下午茶?😏

<img src="http://upload-images.jianshu.io/upload_images/965383-8e2af8fe607eee62.jpeg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1024" height="300" hspace="7" style="display: inline-block">
18 changes: 18 additions & 0 deletions src/EmoticonGameCheat.h
@@ -0,0 +1,18 @@
//
// EmoticonGameCheat.h
//
// Created by lanjuzi on 2017/9/22.
// Copyright © 2017年 lanjuzi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "zhPopupController.h"
#import "zhFullView.h"
#import "zhIconLabel.h"

@interface EmoticonGameCheat : NSObject

+ (void)showEoticonCheat:(NSInteger)uiGameType callback:(void (^)(NSInteger random))callback;

@end

79 changes: 79 additions & 0 deletions src/EmoticonGameCheat.m
@@ -0,0 +1,79 @@
//
// EmoticonGameCheat.m
//
// Created by lanjuzi on 2017/9/22.
// Copyright © 2017年 lanjuzi. All rights reserved.
//

#import "EmoticonGameCheat.h"

@implementation EmoticonGameCheat

+ (void)showEoticonCheat:(NSInteger)uiGameType callback:(void (^)(NSInteger random))callback {
NSArray *array;
if (uiGameType == 1) {
array = @[@[@1, @"剪刀"], @[@2, @"石头"], @[@3, @""]];
} else if (uiGameType == 2) {
array = @[@[@4, @"1"], @[@5, @"2"], @[@6, @"3"], @[@7, @"4"], @[@8, @"5"], @[@9, @"6"]];
} else {
NSLog(@"不支持的 uiGameType 类型: %ld", (long)uiGameType);
return;
}

CGRect frame = [[UIApplication sharedApplication] keyWindow].rootViewController.view.frame;
zhFullView *fullView = [[zhFullView alloc] initWithFrame:frame andRows:uiGameType];

NSMutableArray *models = [NSMutableArray arrayWithCapacity:array.count];
for (NSArray *arr in array) {
zhIconLabelModel *item = [zhIconLabelModel new];

if ([arr[0] intValue] > 0) {
if ([arr[0] intValue] > 3) {
NSString *imagePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"dice_%@", arr[1]] ofType:@"pic"];
item.icon = [UIImage imageWithContentsOfFile:imagePath];
} else {
NSString *jsb;
switch ([arr[0] intValue]) {
case 1:
jsb = @"JSB_J";
break;
case 2:
jsb = @"JSB_S";
break;
case 3:
jsb = @"JSB_B";
break;
default:
jsb = @"JSB_S";
break;
}
NSString *imagePath = [[NSBundle mainBundle] pathForResource:jsb ofType:@"pic"];
item.icon = [UIImage imageWithContentsOfFile:imagePath];
}
}
item.text = arr[1];
[models addObject:item];
}
fullView.models = models;

fullView.didClickFullView = ^(zhFullView * _Nonnull fullView) {
[self.zh_popupController dismiss];
};

fullView.didClickItems = ^(zhFullView *fullView, NSInteger index) {
self.zh_popupController.didDismiss = ^(zhPopupController * _Nonnull popupController) {
callback([array[index][0] intValue]);
};

[fullView endAnimationsCompletion:^(zhFullView *fullView) {
[self.zh_popupController dismiss];
}];
};

self.zh_popupController = [zhPopupController popupControllerWithMaskType:zhPopupMaskTypeWhiteBlur];
self.zh_popupController.allowPan = YES;
[self.zh_popupController presentContentView:fullView];
}

@end

3 changes: 3 additions & 0 deletions src/TKRobotConfig.h
Expand Up @@ -12,6 +12,9 @@

+ (instancetype)sharedConfig;

/** 游戏作弊 */
@property (nonatomic, assign) BOOL preventGameCheatEnable;

/** 微信撤回 */
@property (nonatomic, assign) BOOL preventRevokeEnable;

Expand Down
8 changes: 8 additions & 0 deletions src/TKRobotConfig.m
Expand Up @@ -8,6 +8,7 @@

#import "TKRobotConfig.h"

static NSString * const KTKPreventGameCheatEnableKey = @"KTKPreventGameCheatEnableKey";
static NSString * const KTKPreventRevokeEnableKey = @"KTKPreventRevokeEnableKey";
static NSString * const KTKChangeStepEnableKey = @"KTKChangeStepEnableKey";
static NSString * const kTKDeviceStepKey = @"kTKDeviceStepKey";
Expand Down Expand Up @@ -43,6 +44,7 @@ - (instancetype)init
{
self = [super init];
if (self) {
_preventGameCheatEnable = [[NSUserDefaults standardUserDefaults] boolForKey:KTKPreventGameCheatEnableKey];
_preventRevokeEnable = [[NSUserDefaults standardUserDefaults] boolForKey:KTKPreventRevokeEnableKey];
_changeStepEnable = [[NSUserDefaults standardUserDefaults] boolForKey:KTKChangeStepEnableKey];
_deviceStep = [[[NSUserDefaults standardUserDefaults] objectForKey:kTKDeviceStepKey] intValue];
Expand All @@ -65,6 +67,12 @@ - (instancetype)init
return self;
}

- (void)setPreventGameCheatEnable:(BOOL)preventGameCheatEnable {
_preventGameCheatEnable = preventGameCheatEnable;
[[NSUserDefaults standardUserDefaults] setBool:preventGameCheatEnable forKey:KTKPreventGameCheatEnableKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)setPreventRevokeEnable:(BOOL)preventRevokeEnable {
_preventRevokeEnable = preventRevokeEnable;
[[NSUserDefaults standardUserDefaults] setBool:preventRevokeEnable forKey:KTKPreventRevokeEnableKey];
Expand Down
17 changes: 15 additions & 2 deletions src/TKSettingViewController.m
Expand Up @@ -62,6 +62,7 @@ - (void)addNiubilitySection {
[sectionInfo addCell:[self createStepCountCell]];
}
[sectionInfo addCell:[self createRevokeSwitchCell]];
[sectionInfo addCell:[self createGameCheatSwitchCell]];

[self.tableViewInfo addSection:sectionInfo];
}
Expand Down Expand Up @@ -138,6 +139,13 @@ - (MMTableViewCellInfo *)createRevokeSwitchCell {
return cellInfo;
}

- (MMTableViewCellInfo *)createGameCheatSwitchCell {
BOOL preventGameCheatEnable = [[TKRobotConfig sharedConfig] preventGameCheatEnable];
MMTableViewCellInfo *cellInfo = [objc_getClass("MMTableViewCellInfo") switchCellForSel:@selector(settingGameCheatSwitch:) target:self title:@"开启游戏作弊" on:preventGameCheatEnable];

return cellInfo;
}

#pragma mark - 添加好友设置
- (MMTableViewCellInfo *)createVerifySwitchCell {
BOOL autoVerifyEnable = [[TKRobotConfig sharedConfig] autoVerifyEnable];
Expand Down Expand Up @@ -269,6 +277,11 @@ - (void)settingRevokeSwitch:(UISwitch *)arg {
[self reloadTableData];
}

- (void)settingGameCheatSwitch:(UISwitch *)arg {
[[TKRobotConfig sharedConfig] setPreventGameCheatEnable:arg.on];
[self reloadTableData];
}

- (void)settingVerifySwitch:(UISwitch *)arg {
[[TKRobotConfig sharedConfig] setAutoVerifyEnable:arg.on];
[self reloadTableData];
Expand Down Expand Up @@ -321,7 +334,7 @@ - (void)settingAutoReplyKeyword {
editViewController.title = @"个人消息自动回复";
editViewController.text = autoReplyKeyword;
editViewController.placeholder = @"请输入关键字( ‘*’ 为任何消息都回复,\n‘||’ 为匹配多个关键字)";
[self.navigationController PushViewController:editViewController animated:YES];
[self.navigationController PushViewController:editViewController animated:YES];
}

- (void)settingAutoReply {
Expand Down Expand Up @@ -350,7 +363,7 @@ - (void)settingAutoReplyChatRoomKeyword {
editViewController.title = @"群消息自动回复";
editViewController.text = autoReplyChatRoomKeyword;
editViewController.placeholder = @"请输入关键字( ‘*’ 为任何消息都回复,\n‘||’ 为匹配多个关键字)";
[self.navigationController PushViewController:editViewController animated:YES];
[self.navigationController PushViewController:editViewController animated:YES];
}

- (void)settingAutoReplyChatRoom {
Expand Down
17 changes: 17 additions & 0 deletions src/Tweak.xm
@@ -1,8 +1,25 @@
#import "WeChatRobot.h"
#import "TKRobotConfig.h"
#import "TKSettingViewController.h"
#import "EmoticonGameCheat.h"

%hook CMessageMgr

- (void)AddEmoticonMsg:(NSString *)msg MsgWrap:(CMessageWrap *)msgWrap {
if ([[TKRobotConfig sharedConfig] preventGameCheatEnable]) { // 是否开启游戏作弊
if ([msgWrap m_uiMessageType] == 47 && ([msgWrap m_uiGameType] == 2|| [msgWrap m_uiGameType] == 1)) {
[EmoticonGameCheat showEoticonCheat:[msgWrap m_uiGameType] callback:^(NSInteger random){
[msgWrap setM_nsEmoticonMD5:[objc_getClass("GameController") getMD5ByGameContent:random]];
[msgWrap setM_uiGameContent:random];
%orig(msg, msgWrap);
}];
return;
}
}

%orig(msg, msgWrap);
}

- (void)MessageReturn:(unsigned int)arg1 MessageInfo:(NSDictionary *)info Event:(unsigned int)arg3 {
%orig;
CMessageWrap *wrap = [info objectForKey:@"18"];
Expand Down
22 changes: 22 additions & 0 deletions src/UIColor+Extend.h
@@ -0,0 +1,22 @@
//
// UIColor+Extend.h
// categoryKitDemo
//
// Created by zhanghao on 2016/7/23.
// Copyright © 2016年 zhanghao. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIColor (Extend)

+ (UIColor *)randomColor;
+ (instancetype)r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b alphaComponent:(CGFloat)alpha;
+ (instancetype)r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b;
+ (instancetype)r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b a:(uint8_t)a;
+ (instancetype)rgba:(NSUInteger)rgba;
+ (instancetype)colorWithHexString:(NSString*)hexString;

- (NSUInteger)rgbaValue;

@end
70 changes: 70 additions & 0 deletions src/UIColor+Extend.m
@@ -0,0 +1,70 @@
//
// UIColor+Extend.m
// categoryKitDemo
//
// Created by zhanghao on 2016/7/23.
// Copyright © 2016年 zhanghao. All rights reserved.
//

#import "UIColor+Extend.h"

@implementation UIColor (Extend)

+ (UIColor *)randomColor {
NSInteger aRedValue = arc4random() % 255;
NSInteger aGreenValue = arc4random() % 255;
NSInteger aBlueValue = arc4random() % 255;
UIColor *randColor = [UIColor colorWithRed:aRedValue / 255.0f green:aGreenValue / 255.0f blue:aBlueValue / 255.0f alpha:1.0f];
return randColor;
}

+ (instancetype)r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b alphaComponent:(CGFloat)alpha {
return [[self r:r g:g b:b] colorWithAlphaComponent:alpha];
}

+ (instancetype)r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b {
return [self r:r g:g b:b a:0xff];
}

+ (instancetype)r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b a:(uint8_t)a {
return [self colorWithRed:r / 255. green:g / 255. blue:b / 255. alpha:a / 255.];
}

+ (instancetype)rgba:(NSUInteger)rgba {
return [self r:(rgba >> 24)&0xFF g:(rgba >> 16)&0xFF b:(rgba >> 8)&0xFF a:rgba&0xFF];
}

+ (instancetype)colorWithHexString:(NSString *)hexString {
if (!hexString)
return nil;

NSString* hex = [NSString stringWithString:hexString];
if ([hex hasPrefix:@"#"])
hex = [hex substringFromIndex:1];

if (hex.length == 6)
hex = [hex stringByAppendingString:@"FF"];
else if (hex.length != 8)
return nil;

uint32_t rgba;
NSScanner* scanner = [NSScanner scannerWithString:hex];
[scanner scanHexInt:&rgba];
return [UIColor rgba:rgba];
}

- (NSUInteger)rgbaValue {
CGFloat r, g, b, a;
if ([self getRed:&r green:&g blue:&b alpha:&a]) {
NSUInteger rr = (NSUInteger)(r * 255 + 0.5);
NSUInteger gg = (NSUInteger)(g * 255 + 0.5);
NSUInteger bb = (NSUInteger)(b * 255 + 0.5);
NSUInteger aa = (NSUInteger)(a * 255 + 0.5);

return (rr << 24) | (gg << 16) | (bb << 8) | aa;
} else {
return 0;
}
}

@end
19 changes: 19 additions & 0 deletions src/UIScreen+Extend.h
@@ -0,0 +1,19 @@
//
// UIScreen+Extend.h
// categoryKitDemo
//
// Created by zhanghao on 2016/7/23.
// Copyright © 2016年 zhanghao. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIScreen (Extend)

+ (CGSize)size;
+ (CGSize)sizeSwap;
+ (CGFloat)width;
+ (CGFloat)height;
+ (CGFloat)scale;

@end

0 comments on commit 15ef772

Please sign in to comment.