Created
October 10, 2013 18:08
-
-
Save RobertAudi/6922856 to your computer and use it in GitHub Desktop.
`skype help`
This file contains hidden or 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
#!/usr/local/bin/zsh | |
if [[ $1 = "auth" ]]; then | |
echo "Authorizing this script with Skype..." | |
osascript <<-APPLESCRIPT | |
tell application "Skype" | |
set onlineStatus to send command "GET USER " & "$contact" & " ONLINESTATUS" script name "getType" | |
end tell | |
set status to word 4 of onlineStatus | |
return | |
APPLESCRIPT | |
elif [[ $1 = "call" ]]; then | |
skypename="$(cat $HOME/.skyperc | grep -iw $2)" | |
numomatches="$(echo $skypename | wc -l | sed 's/ //g')" | |
if [[ $numomatches != "1" ]]; then | |
echo "Too many or not enough matches. Refine your query please." | |
echo "Matches:" | |
echo $skypename | |
else | |
contact="$(echo $skypename | sed 's/,.*//g')" | |
contactstatus="$(osascript <<-APPLESCRIPT | |
tell application "Skype" | |
set onlineStatus to send command "GET USER " & "$contact" & " ONLINESTATUS" script name "getType" | |
end tell | |
set status to word 4 of onlineStatus | |
if status is "ONLINE" or status is "AWAY" or status is "DND" or status is "NA" then | |
return status | |
end if | |
APPLESCRIPT)" | |
if [[ $contactstatus != "ONLINE" ]]; then | |
echo "User not available..." | |
else | |
echo "Calling $(echo $skypename | sed 's/.*,//g')" | |
osascript <<-APPLESCRIPT | |
tell application "Skype" | |
activate | |
delay 2 | |
tell application "System Events" to keystroke return | |
get URL "skype:$contact?call" | |
end tell | |
-- tell application "iTerm" to activate | |
APPLESCRIPT | |
fi | |
fi | |
elif [[ $1 = "who" || $1 = "online" ]]; then | |
online_contacts=() | |
for contact in $(cat $HOME/.skyperc | sed 's/,.*//g') | |
do | |
online_contact="$(osascript <<-APPLESCRIPT | |
tell application "Skype" | |
set onlineStatus to send command "GET USER " & "$contact" & " ONLINESTATUS" script name "getType" | |
end tell | |
set status to word 4 of onlineStatus | |
if status is "ONLINE" or status is "AWAY" or status is "DND" or status is "NA" then | |
return "$contact" | |
end if | |
APPLESCRIPT)" | |
if [[ $online_contact != "" ]]; then | |
# echo "$(cat $HOME/.skyperc | grep $online_contact | sed 's/.*,//g' | sed 's/"//g')" | |
# online_contacts+=("$online_contact") | |
online_contacts+=("$online_contact") | |
fi | |
done | |
for contact in $online_contacts | |
do | |
echo "$(cat $HOME/.skyperc | grep $contact | sed 's/.*,//g' | sed 's/"//g')" | |
done | |
elif [[ $1 = "help" ]]; then | |
echo "Usage: skype [command]" | |
printf "\t%-15s %15s\n" "help" "Show this help message" | |
printf "\t%-15s %15s\n" "auth" "Authenticate with Skype" | |
printf "\t%-15s %15s\n" "who" "Show online contacts" | |
printf "\t%-15s %15s\n" "online" "Show online contacts" | |
printf "\t%-14s %15s\n" "call contact" "Call a contact" | |
echo "NOTE: RUN \`skype auth\` THE FIRST TIME!!!!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment