diff --git a/CHANGELOG.md b/CHANGELOG.md index fb95d1e6..6ff6efd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +### [v1.5.1 (2018-03-03)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.1) + +* 新增语音远程控制 mac +* 修复快捷回复后消息未读数未更新的问题 +* 优化防撤回提醒 (显示撤回人昵称 & 消息类型) + ### [v1.5.0 (2018-02-24)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.0) * 优化防撤回提醒 diff --git a/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h b/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h index 27b9b79a..6a7fb74f 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h +++ b/Other/Products/Debug/WeChatPlugin.framework/Headers/WeChatPlugin.h @@ -47,6 +47,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (id)SendTextMessage:(id)arg1 toUsrName:(id)arg2 msgText:(id)arg3 atUserList:(id)arg4; - (id)GetMsgData:(id)arg1 svrId:(long)arg2; - (void)AddLocalMsg:(id)arg1 msgData:(id)arg2; +- (void)TranscribeVoiceMessage:(id)arg1 completion:(void (^)(void))arg2; +- (BOOL)ClearUnRead:(id)arg1 FromID:(unsigned int)arg2 ToID:(unsigned int)arg3; @end @interface MMServiceCenter : NSObject @@ -64,6 +66,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic, setter=SetMsgType:) int msgType; // @synthesize msgType; @property(retain, nonatomic, setter=SetToUserName:) SKBuiltinString_t *toUserName; // @synthesize toUserName; @property (nonatomic, assign) unsigned int createTime; +@property(nonatomic, setter=SetNewMsgId:) long long newMsgId; @end @interface MMChatsViewController : NSViewController @@ -99,6 +102,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic) int msgStatus; @property(nonatomic) int msgCreateTime; @property(nonatomic) int mesLocalID; +@property(nonatomic) long long mesSvrID; +@property(retain, nonatomic) NSString *msgVoiceText; @property(copy, nonatomic) NSString *m_nsEmoticonMD5; - (BOOL)isChatRoomMessage; - (id)groupChatSenderDisplayName; diff --git a/Other/Products/Debug/WeChatPlugin.framework/Resources/Info.plist b/Other/Products/Debug/WeChatPlugin.framework/Resources/Info.plist index 80e275a2..c1877b77 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Resources/Info.plist +++ b/Other/Products/Debug/WeChatPlugin.framework/Resources/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.0 + 1.5.1 CFBundleSupportedPlatforms MacOSX @@ -41,6 +41,6 @@ NSHumanReadableCopyright Copyright © 2017年 tk. All rights reserved. versionInfo - 👉 优化防撤回提醒 \n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n + 👉 v1.5.1 (2018-03-03):\n新增语音远程控制 mac\n修复快捷回复后消息未读数未更新的问题\n优化防撤回提醒 (显示撤回人昵称 & 消息类型) \n\n上版本更新内容(v1.5.0):\n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h index 27b9b79a..6a7fb74f 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Headers/WeChatPlugin.h @@ -47,6 +47,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (id)SendTextMessage:(id)arg1 toUsrName:(id)arg2 msgText:(id)arg3 atUserList:(id)arg4; - (id)GetMsgData:(id)arg1 svrId:(long)arg2; - (void)AddLocalMsg:(id)arg1 msgData:(id)arg2; +- (void)TranscribeVoiceMessage:(id)arg1 completion:(void (^)(void))arg2; +- (BOOL)ClearUnRead:(id)arg1 FromID:(unsigned int)arg2 ToID:(unsigned int)arg3; @end @interface MMServiceCenter : NSObject @@ -64,6 +66,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic, setter=SetMsgType:) int msgType; // @synthesize msgType; @property(retain, nonatomic, setter=SetToUserName:) SKBuiltinString_t *toUserName; // @synthesize toUserName; @property (nonatomic, assign) unsigned int createTime; +@property(nonatomic, setter=SetNewMsgId:) long long newMsgId; @end @interface MMChatsViewController : NSViewController @@ -99,6 +102,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic) int msgStatus; @property(nonatomic) int msgCreateTime; @property(nonatomic) int mesLocalID; +@property(nonatomic) long long mesSvrID; +@property(retain, nonatomic) NSString *msgVoiceText; @property(copy, nonatomic) NSString *m_nsEmoticonMD5; - (BOOL)isChatRoomMessage; - (id)groupChatSenderDisplayName; diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Resources/Info.plist b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Resources/Info.plist index 80e275a2..c1877b77 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Resources/Info.plist +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/Resources/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.0 + 1.5.1 CFBundleSupportedPlatforms MacOSX @@ -41,6 +41,6 @@ NSHumanReadableCopyright Copyright © 2017年 tk. All rights reserved. versionInfo - 👉 优化防撤回提醒 \n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n + 👉 v1.5.1 (2018-03-03):\n新增语音远程控制 mac\n修复快捷回复后消息未读数未更新的问题\n优化防撤回提醒 (显示撤回人昵称 & 消息类型) \n\n上版本更新内容(v1.5.0):\n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin index fd01ab32..51ff5ba1 100755 Binary files a/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin and b/Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin differ diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h index 27b9b79a..6a7fb74f 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Headers/WeChatPlugin.h @@ -47,6 +47,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (id)SendTextMessage:(id)arg1 toUsrName:(id)arg2 msgText:(id)arg3 atUserList:(id)arg4; - (id)GetMsgData:(id)arg1 svrId:(long)arg2; - (void)AddLocalMsg:(id)arg1 msgData:(id)arg2; +- (void)TranscribeVoiceMessage:(id)arg1 completion:(void (^)(void))arg2; +- (BOOL)ClearUnRead:(id)arg1 FromID:(unsigned int)arg2 ToID:(unsigned int)arg3; @end @interface MMServiceCenter : NSObject @@ -64,6 +66,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic, setter=SetMsgType:) int msgType; // @synthesize msgType; @property(retain, nonatomic, setter=SetToUserName:) SKBuiltinString_t *toUserName; // @synthesize toUserName; @property (nonatomic, assign) unsigned int createTime; +@property(nonatomic, setter=SetNewMsgId:) long long newMsgId; @end @interface MMChatsViewController : NSViewController @@ -99,6 +102,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic) int msgStatus; @property(nonatomic) int msgCreateTime; @property(nonatomic) int mesLocalID; +@property(nonatomic) long long mesSvrID; +@property(retain, nonatomic) NSString *msgVoiceText; @property(copy, nonatomic) NSString *m_nsEmoticonMD5; - (BOOL)isChatRoomMessage; - (id)groupChatSenderDisplayName; diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Resources/Info.plist b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Resources/Info.plist index 80e275a2..c1877b77 100644 --- a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Resources/Info.plist +++ b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/Resources/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.0 + 1.5.1 CFBundleSupportedPlatforms MacOSX @@ -41,6 +41,6 @@ NSHumanReadableCopyright Copyright © 2017年 tk. All rights reserved. versionInfo - 👉 优化防撤回提醒 \n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n + 👉 v1.5.1 (2018-03-03):\n新增语音远程控制 mac\n修复快捷回复后消息未读数未更新的问题\n优化防撤回提醒 (显示撤回人昵称 & 消息类型) \n\n上版本更新内容(v1.5.0):\n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n diff --git a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin index fd01ab32..51ff5ba1 100755 Binary files a/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin and b/Other/Products/Debug/WeChatPlugin.framework/Versions/Current/WeChatPlugin differ diff --git a/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin b/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin index fd01ab32..51ff5ba1 100755 Binary files a/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin and b/Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin differ diff --git a/Other/ScreenShots/voice_remote_control.gif b/Other/ScreenShots/voice_remote_control.gif new file mode 100644 index 00000000..c5d9fca9 Binary files /dev/null and b/Other/ScreenShots/voice_remote_control.gif differ diff --git a/README.md b/README.md index be229643..4ac8306a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ ## WeChatPlugin-MacOS -![platform](https://img.shields.io/badge/platform-macos-lightgrey.svg) [![release](https://img.shields.io/badge/release-v1.5.0-brightgreen.svg)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases) ![support](https://img.shields.io/badge/support-wechat%202.3.10-blue.svg) [![GitHub license](https://img.shields.io/github/license/TKkk-iOSer/WeChatPlugin-MacOS.svg)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/blob/master/LICENSE) +![platform](https://img.shields.io/badge/platform-macos-lightgrey.svg) [![release](https://img.shields.io/badge/release-v1.5.1-brightgreen.svg)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases) ![support](https://img.shields.io/badge/support-wechat%202.3.10-blue.svg) [![GitHub license](https://img.shields.io/github/license/TKkk-iOSer/WeChatPlugin-MacOS.svg)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/blob/master/LICENSE) - -微信小助手 v1.5.0 +微信小助手 v1.5.1 ![微信小助手.png](./Other/ScreenShots/wechatplugin.png) @@ -16,16 +15,17 @@ --- ### 更新日志 +* [新增语音远程控制mac & 优化撤回消息、快捷回复(2018-03-03)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.0) -[新增小助手检测更新&表情包复制存储等等 (2018-02-24)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.0) +* [新增小助手检测更新&表情包复制存储等等 (2018-02-24)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.0) -[新增窗口置顶&多选删除等等 (2017-10-11)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.4.0) +* [新增窗口置顶&多选删除等等 (2017-10-11)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.4.0) -[新增置底&免认证 (2017-09-17)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.3.0) +* [新增置底&免认证 (2017-09-17)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.3.0) -[修复聊天记录消失的bug (2017-09-11)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.2.0) +* [修复聊天记录消失的bug (2017-09-11)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.2.0) -[重构自动回复,实现多回复 (2017-08-23)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.1.0) +* [重构自动回复,实现多回复 (2017-08-23)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.1.0) **详细内容请查看**[CHANGELOG](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/blob/master/CHANGELOG.md) @@ -34,7 +34,7 @@ ### 功能 * 消息自动回复 * 消息防撤回 -* 远程控制 +* 远程控制(已支持语音) * 微信多开 * 第二次登录免认证 * 聊天置底功能(~~类似置顶~~) @@ -68,6 +68,7 @@ - [x] 完善消息防撤回(显示撤回用户昵称) - [x] ~~清除微信缓存(官方已加)~~ - [x] 优化小助手设置(更新后保留相关设置,更新提醒) +- [x] 语音远程控制mac - [ ] 群聊屏蔽某成员 --- @@ -95,6 +96,10 @@ * 聊天窗口表情复制 & 存储 +* 语音远程控制 +![语音远程控制](./Other/ScreenShots/voice_remote_control.gif) + + --- ### 安装 @@ -109,8 +114,7 @@ **1. 普通安装** -* 点击`clone or download`按钮下载 WeChatPlugin 至`下载`目录并解压到`下载`目录,打开Termimal,执行 `~/Downloads/WeChatPlugin-MacOS-master/Other/Install.sh`即可。 - +* 点击`clone or download`按钮下载 WeChatPlugin 并解压,打开Terminal(终端),拖动解压后`Install.sh` 文件(在 Other 文件夹中)到 Terminal 回车即可。 **2. 若想修改源码&重编译** diff --git a/WeChatPlugin.xcodeproj/project.xcworkspace/xcuserdata/TK.xcuserdatad/UserInterfaceState.xcuserstate b/WeChatPlugin.xcodeproj/project.xcworkspace/xcuserdata/TK.xcuserdatad/UserInterfaceState.xcuserstate index 5ef5b36d..3595e24a 100644 Binary files a/WeChatPlugin.xcodeproj/project.xcworkspace/xcuserdata/TK.xcuserdatad/UserInterfaceState.xcuserstate and b/WeChatPlugin.xcodeproj/project.xcworkspace/xcuserdata/TK.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/WeChatPlugin.xcodeproj/xcuserdata/TK.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/WeChatPlugin.xcodeproj/xcuserdata/TK.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index fe2b4541..f3337043 100644 --- a/WeChatPlugin.xcodeproj/xcuserdata/TK.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/WeChatPlugin.xcodeproj/xcuserdata/TK.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,22 @@ + + + + + + diff --git a/WeChatPlugin/Info.plist b/WeChatPlugin/Info.plist index a6ac65e7..32279fcc 100644 --- a/WeChatPlugin/Info.plist +++ b/WeChatPlugin/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5.0 + 1.5.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSHumanReadableCopyright @@ -23,6 +23,6 @@ NSPrincipalClass versionInfo - 👉 优化防撤回提醒 \n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n + 👉 v1.5.1 (2018-03-03):\n新增语音远程控制 mac\n修复快捷回复后消息未读数未更新的问题\n优化防撤回提醒 (显示撤回人昵称 & 消息类型) \n\n上版本更新内容(v1.5.0):\n👉🏻 新增自动登录开关 \n👉🏼 新增小助手检测更新 \n👉🏽 新增通知中心快捷回复 \n👉🏾 新增表情包复制 & 存储 \n👉🏿 自动回复 & 远程控制设置存储到本地 \n\n diff --git a/WeChatPlugin/Sources/Category/WeChat+hook.m b/WeChatPlugin/Sources/Category/WeChat+hook.m index 737f0707..7df506d3 100644 --- a/WeChatPlugin/Sources/Category/WeChat+hook.m +++ b/WeChatPlugin/Sources/Category/WeChat+hook.m @@ -96,7 +96,7 @@ + (void)addAssistantMenuItem { // 登录新微信 NSMenuItem *newWeChatItem = [[NSMenuItem alloc] initWithTitle:@"登录新微信" action:@selector(onNewWechatInstance:) keyEquivalent:@"N"]; // 远程控制 - NSMenuItem *commandItem = [[NSMenuItem alloc] initWithTitle:@"远程控制Mac OS" action:@selector(onRemoteControl:) keyEquivalent:@"C"]; + NSMenuItem *commandItem = [[NSMenuItem alloc] initWithTitle:@"远程控制mac" action:@selector(onRemoteControl:) keyEquivalent:@"C"]; // 微信窗口置顶 NSMenuItem *onTopItem = [[NSMenuItem alloc] initWithTitle:@"微信窗口置顶" action:@selector(onWechatOnTopControl:) keyEquivalent:@"d"]; onTopItem.state = [[TKWeChatPluginConfig sharedConfig] onTop]; @@ -385,6 +385,7 @@ - (void)hook_userNotificationCenter:(id)notificationCenter didActivateNotificati if ([instanceUserName isEqualToString:currentUserName]) { MessageService *service = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MessageService")]; [service SendTextMessage:currentUserName toUsrName:chatName msgText:notification.response.string atUserList:nil]; + [service ClearUnRead:chatName FromID:0 ToID:0]; } } else { [self hook_userNotificationCenter:notificationCenter didActivateNotification:notification]; @@ -545,6 +546,18 @@ - (void)autoReplyWithMsg:(AddMsg *)addMsg { - (void)remoteControlWithMsg:(AddMsg *)addMsg { if (addMsg.msgType == 1 || addMsg.msgType == 3) { [TKRemoteControlController executeRemoteControlCommandWithMsg:addMsg.content.string]; + } else if (addMsg.msgType == 34) { + // 此为语音消息 + MessageService *msgService = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MessageService")]; + MessageData *msgData = [msgService GetMsgData:addMsg.fromUserName.string svrId:addMsg.newMsgId]; + long long mesSvrID = msgData.mesSvrID; + NSString *sessionName = msgData.fromUsrName; + [msgService TranscribeVoiceMessage:msgData completion:^ { + MessageData *callbackMsgData = [msgService GetMsgData:sessionName svrId:mesSvrID]; + dispatch_async(dispatch_get_main_queue(), ^{ + [TKRemoteControlController executeRemoteControlCommandWithVoiceMsg:callbackMsgData.msgVoiceText]; + }); + }]; } } diff --git a/WeChatPlugin/Sources/Controllers/TKRemoteControlController.h b/WeChatPlugin/Sources/Controllers/TKRemoteControlController.h index 29ad7d03..30b5e018 100644 --- a/WeChatPlugin/Sources/Controllers/TKRemoteControlController.h +++ b/WeChatPlugin/Sources/Controllers/TKRemoteControlController.h @@ -10,6 +10,7 @@ @interface TKRemoteControlController : NSObject ++ (void)executeRemoteControlCommandWithVoiceMsg:(NSString *)msg; + (void)executeRemoteControlCommandWithMsg:(NSString *)msg; + (void)executeShellCommand:(NSString *)msg; + (NSString *)remoteControlCommandsString; diff --git a/WeChatPlugin/Sources/Controllers/TKRemoteControlController.m b/WeChatPlugin/Sources/Controllers/TKRemoteControlController.m index 2334092b..17539bee 100644 --- a/WeChatPlugin/Sources/Controllers/TKRemoteControlController.m +++ b/WeChatPlugin/Sources/Controllers/TKRemoteControlController.m @@ -11,16 +11,34 @@ #import "TKRemoteControlModel.h" #import "WeChatPlugin.h" +typedef NS_ENUM(NSUInteger, MessageDataType) { + MessageDataTypeText, + MessageDataTypeVoice +}; + // 执行 AppleScript static NSString * const kRemoteControlAppleScript = @"osascript /Applications/WeChat.app/Contents/MacOS/WeChatPlugin.framework/Resources/TKRemoteControlScript.scpt"; @implementation TKRemoteControlController ++ (void)executeRemoteControlCommandWithVoiceMsg:(NSString *)msg { + NSString *currentUserName = [objc_getClass("CUtility") GetCurrentUserName]; + NSString *callBack = [NSString stringWithFormat:@"小助手收到一条语音消息,转文字后👇👇👇:\n\n\n%@",msg]; + MessageService *service = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MessageService")]; + [service SendTextMessage:currentUserName toUsrName:currentUserName msgText:callBack atUserList:nil]; + + [self executeRemoteControlCommandWithMsg:msg msgType:MessageDataTypeVoice]; +} + + (void)executeRemoteControlCommandWithMsg:(NSString *)msg { + [self executeRemoteControlCommandWithMsg:msg msgType:MessageDataTypeText]; +} + ++ (void)executeRemoteControlCommandWithMsg:(NSString *)msg msgType:(MessageDataType)type { NSArray *remoteControlModels = [TKWeChatPluginConfig sharedConfig].remoteControlModels; [remoteControlModels enumerateObjectsUsingBlock:^(NSArray *subModels, NSUInteger index, BOOL * _Nonnull stop) { - [subModels enumerateObjectsUsingBlock:^(TKRemoteControlModel *model, NSUInteger idx, BOOL * _Nonnull stop) { - if (model.enable && ![model.keyword isEqualToString:@""] && [msg isEqualToString:model.keyword]) { + [subModels enumerateObjectsUsingBlock:^(TKRemoteControlModel *model, NSUInteger idx, BOOL * _Nonnull subStop) { + if ([self sholdExecuteRemoteControlWithModel:model msg:msg msgType:type]) { if ([model.function isEqualToString:@"屏幕保护"] || [model.function isEqualToString:@"锁屏"]) { // 屏幕保护 & 锁屏 通过 Shell 命令来执行即可 [self executeShellCommand:model.executeCommand]; @@ -40,11 +58,25 @@ + (void)executeRemoteControlCommandWithMsg:(NSString *)msg { NSString *callBack = [NSString stringWithFormat:@"小助手收到一条指令:%@",model.function]; MessageService *service = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MessageService")]; [service SendTextMessage:currentUserName toUsrName:currentUserName msgText:callBack atUserList:nil]; + *stop = YES; + *subStop = YES; } }]; }]; } ++ (BOOL)sholdExecuteRemoteControlWithModel:(TKRemoteControlModel *)model msg:(NSString *)msg msgType:(MessageDataType)type { + if (model.enable && ![model.keyword isEqualToString:@""]) { + if ((type == MessageDataTypeText && [msg isEqualToString:model.keyword]) || (type == MessageDataTypeVoice && [msg containsString:model.keyword])) { + return YES; + } else { + return NO; + } + } else { + return NO; + } +} + /** 通过 NSTask 执行 Shell 命令 diff --git a/WeChatPlugin/WeChatPlugin.h b/WeChatPlugin/WeChatPlugin.h index 27b9b79a..6a7fb74f 100644 --- a/WeChatPlugin/WeChatPlugin.h +++ b/WeChatPlugin/WeChatPlugin.h @@ -47,6 +47,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; - (id)SendTextMessage:(id)arg1 toUsrName:(id)arg2 msgText:(id)arg3 atUserList:(id)arg4; - (id)GetMsgData:(id)arg1 svrId:(long)arg2; - (void)AddLocalMsg:(id)arg1 msgData:(id)arg2; +- (void)TranscribeVoiceMessage:(id)arg1 completion:(void (^)(void))arg2; +- (BOOL)ClearUnRead:(id)arg1 FromID:(unsigned int)arg2 ToID:(unsigned int)arg3; @end @interface MMServiceCenter : NSObject @@ -64,6 +66,7 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic, setter=SetMsgType:) int msgType; // @synthesize msgType; @property(retain, nonatomic, setter=SetToUserName:) SKBuiltinString_t *toUserName; // @synthesize toUserName; @property (nonatomic, assign) unsigned int createTime; +@property(nonatomic, setter=SetNewMsgId:) long long newMsgId; @end @interface MMChatsViewController : NSViewController @@ -99,6 +102,8 @@ FOUNDATION_EXPORT const unsigned char WeChatPluginVersionString[]; @property(nonatomic) int msgStatus; @property(nonatomic) int msgCreateTime; @property(nonatomic) int mesLocalID; +@property(nonatomic) long long mesSvrID; +@property(retain, nonatomic) NSString *msgVoiceText; @property(copy, nonatomic) NSString *m_nsEmoticonMD5; - (BOOL)isChatRoomMessage; - (id)groupChatSenderDisplayName;