-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweak.xm
32 lines (27 loc) · 1.29 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#import <CoreTelephony/CTMessageCenter.h>
#import <ChatKit/CKSMSMessage.h>
#import <ChatKit/CKSMSEntity.h>
#import <ChatKit/CKSMSService.h>
#import <ChatKit/CKConversation.h>
%hook SBSMSManager
NSString *sendersMessageString;
NSString *senderNumber;
-(id)messageReceived:(NSNotification *)message {
NSDictionary *settingsDict = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.legendcoders.awaytext.plist"];
BOOL autoReply = [[settingsDict objectForKey:@"OnOff"] boolValue];
NSString *replyMessage = [settingsDict objectForKey:@"replyMessage"];
if(autoReply) {
NSDictionary *userInfo=[message valueForKey:@"userInfo"];
CKSMSMessage *actualMessage=[userInfo valueForKey:@"CKMessageKey"];
CKSMSEntity *senderAdress = [actualMessage sender];
senderNumber = [senderAdress rawAddress];
sendersMessageString = [actualMessage text];
CKSMSService* service = [objc_getClass("CKSMSService") sharedSMSService];
CKConversationList* SMSList = service.conversationList;
CKConversation* SMSConversation = [SMSList existingConversationForAddresses:[NSArray arrayWithObjects:senderNumber, nil]];
CKSMSMessage* outGoingMessage = [service _newSMSMessageWithText:replyMessage forConversation:SMSConversation];
[service sendMessage:outGoingMessage];
}
return %orig;
}
%end