This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
def cached_token(jsonfile): | |
def has_valid_token(data): | |
return 'token' in data | |
def get_token_from_file(): | |
with open(jsonfile) as f: | |
data = json.load(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Can be used by your scripts to send iMessages from the shell | |
# Usage: | |
# ./SendMessage.sh 1234567890 'hi there!' | |
recipient="${1}" | |
message="${*:2}" | |
cat<<EOF | osascript - "${recipient}" "${message}" | |
on run {targetBuddyPhone, targetMessage} | |
tell application "Messages" | |
set targetService to 1st service whose service type = iMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Event handler | |
using terms from application "Messages" | |
on message received theText from theBuddy for theChat | |
set quoted_message to quoted form of theText | |
set quoted_id to quoted form of (id of theBuddy as text) | |
do shell script "echo " & quoted_message & " | ~/bin/MessageReceive.sh " & quoted_id & " > /dev/null 2>&1 &" | |
# make messages happy | |
return true | |
end message received |