Skip to content

Commit

Permalink
Update ==> 新增 alfred 开关
Browse files Browse the repository at this point in the history
  • Loading branch information
TKkk-iOSer committed Oct 26, 2018
1 parent 4715a01 commit 98f9343
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 5 deletions.
Binary file modified Other/Products/Debug/QQPlugin.framework/QQPlugin
Binary file not shown.
Binary file modified Other/Products/Debug/QQPlugin.framework/Versions/A/QQPlugin
Binary file not shown.
Binary file modified Other/Products/Debug/QQPlugin.framework/Versions/Current/QQPlugin
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,22 @@
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "QQPlugin/Config/TKQQPluginConfig.m"
timestampString = "562261797.636701"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "49"
endingLineNumber = "49"
landmarkName = "-setAlfredEnable:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
19 changes: 18 additions & 1 deletion QQPlugin/Category/QQ+hook.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ - (void)hook_appendReceiveMessageModel:(NSArray *)msgModels msgSource:(long long
- (void)hook_notifyLoginWithAccount:(id)arg1 resultCode:(long long)arg2 userInfo:(id)arg3 {
[self hook_notifyLoginWithAccount:arg1 resultCode:arg2 userInfo:arg3];

[[TKWebServerManager shareManager] startServer];
if ([[TKQQPluginConfig sharedConfig] alfredEnable]) {
[[TKWebServerManager shareManager] startServer];
}
}

- (void)hook_notifyForceLogoutWithAccount:(id)arg1 type:(long long)arg2 tips:(id)arg3 {
Expand Down Expand Up @@ -239,9 +241,14 @@ + (void)addAssistantMenuItem {
// 自动回复
NSMenuItem *autoReplyItem = [[NSMenuItem alloc] initWithTitle:@"自动回复设置" action:@selector(onAutoReply:) keyEquivalent:@"K"];

// 开启 alfred
NSMenuItem *enableAlfredItem = [[NSMenuItem alloc] initWithTitle:@"开启 alfred" action:@selector(onEnableAlfred:) keyEquivalent:@""];
enableAlfredItem.state = [[TKQQPluginConfig sharedConfig] alfredEnable];

NSMenu *subMenu = [[NSMenu alloc] initWithTitle:@"QQ小助手"];
[subMenu addItem:preventRevokeItem];
[subMenu addItem:autoReplyItem];
[subMenu addItem:enableAlfredItem];

NSMenuItem *menuItem = [[NSMenuItem alloc] init];
[menuItem setTitle:@"QQ小助手"];
Expand Down Expand Up @@ -279,6 +286,16 @@ - (void)onAutoReply:(NSMenuItem *)item {
[autoReplyWC.window makeKeyWindow];
}

- (void)onEnableAlfred:(NSMenuItem *)item {
item.state = !item.state;
if (item.state) {
[[TKWebServerManager shareManager] startServer];
} else {
[[TKWebServerManager shareManager] endServer];
}
[[TKQQPluginConfig sharedConfig] setAlfredEnable:item.state];
}

#pragma mark - 替换 NSSearchPathForDirectoriesInDomains & NSHomeDirectory
static NSArray<NSString *> *(*original_NSSearchPathForDirectoriesInDomains)(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde);
NSArray<NSString *> *swizzled_NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde) {
Expand Down
1 change: 1 addition & 0 deletions QQPlugin/Config/TKQQPluginConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@interface TKQQPluginConfig : NSObject

@property (nonatomic, assign) BOOL preventRevokeEnable; /**< 是否开启防撤回 */
@property (nonatomic, assign) BOOL alfredEnable; /**< 是否开启Alfred */
@property (nonatomic, copy) NSMutableArray *autoReplyModels; /**< 自动回复的数组 */

+ (instancetype)sharedConfig;
Expand Down
7 changes: 7 additions & 0 deletions QQPlugin/Config/TKQQPluginConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "TKAutoReplyModel.h"

static NSString * const kTKPreventRevokeEnableKey = @"kTKPreventRevokeEnableKey";
static NSString * const kTKAlfredEnableKey = @"kTKAlfredEnableKey";
static NSString * const kTKQQResourcesPath = @"/Applications/QQ.app/Contents/MacOS/QQPlugin.framework/Resources/";

@interface TKQQPluginConfig ()
Expand All @@ -32,6 +33,7 @@ - (instancetype)init {
self = [super init];
if (self) {
_preventRevokeEnable = [[NSUserDefaults standardUserDefaults] boolForKey:kTKPreventRevokeEnableKey];
_alfredEnable = [[NSUserDefaults standardUserDefaults] boolForKey:kTKAlfredEnableKey];
}
return self;
}
Expand All @@ -42,6 +44,11 @@ - (void)setPreventRevokeEnable:(BOOL)preventRevokeEnable {
[[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)setAlfredEnable:(BOOL)alfredEnable {
_alfredEnable = alfredEnable;
[[NSUserDefaults standardUserDefaults] setBool:alfredEnable forKey:kTKAlfredEnableKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}

#pragma mark - 自动回复
- (NSArray *)autoReplyModels {
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ QQ 小助手
---

### 更新日志
修复安全漏洞(2018-10-23)
* 新增 alfred 开关(2018-10-26)
* 修复安全漏洞(2018-10-23)

---
### 安装
Expand Down Expand Up @@ -86,7 +87,9 @@ QQ 小助手

---

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

<img src="http://upload-images.jianshu.io/upload_images/965383-cbc86dc1d75a6242.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" height="250" hspace="50"/>&nbsp;&nbsp;&nbsp;<img src="http://upload-images.jianshu.io/upload_images/965383-76a1c7c91b987e1a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" height="250" hspace="50" />
### 免责声明
* 使用插件有风险,使用需谨慎。
* 本项目不可用于商业和个人其他意图。若使用不当,请使用者自行承担。
* 如有侵权,请联系本人。[email protected]


0 comments on commit 98f9343

Please sign in to comment.