whoops. Sorry. that is the wrong code. The code I just posted was some startup code. It's also in this script. This is the right code. Its a bit long.
try
set startvol to do shell script "cat ~/alphaassistantdata/startvol.txt "
set volume output volume startvol
end try
set shouldseyi to "Yes"
set mc1 to "false"
set mcexists to get "Minecraft.app"
try
do shell script "ping -o www.apple.com"
set isonline to "true"
on error
set isonline to "false"
end try
set sysinfo to system info
set osver to system version of sysinfo
set ver to "1.2.1"
set shouldwearing to "0"
--get web's version
if isonline is "true" then
set webver to do shell script "curl http://alphateam2.weebly.com/uploads/1/2/2/1/12215941/version.txt"
tell application "Finder"
if ver is greater than webver then
else
set shouldupdate to the button returned of (display dialog "You are running an outdated version of Alpha Assistant. Version " & webver & " is available. Would you like to download the update? " buttons {"Yes", "No"})
if shouldupdate is "Yes" then
tell application "Finder" to set the clipboard to "http://alphateam2.weebly.com/uploads/1/2/2/1/12215941/alpha_assistant.zip"
tell application "System Events"
tell application "Safari" to activate
keystroke "l" using {command down, option down}
keystroke "v" using command down
move file "AlphaAssistant.zip" of "Downloads" to desktop
end tell
end if
end if
end tell
end if
repeat
try
do shell script "ping -o www.apple.com"
set isonline to "true"
on error
set isonline to "false"
end try
if isonline is "true" then
set CityCode to 2424766
--temperature format
set t_format to "F"
--voiceover format
set v_format to "S"
--say present condition
set a_format to "Y"
set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
set file_content to (do shell script "curl " & IURL)
--looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
--today conditions found
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
--looking for actual temperature temperature
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
if t_format is equal to "C" then
set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if
--looking for today forecast
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
--looking for today forecast condition (a bit tricky)
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
end if
set doesexist to "true"
set alphausername to do shell script "cat ~/alphaassistantdata/name.txt "
tell application "SpeechRecognitionServer"
activate
end tell
try
if shouldseyi is "yes" then
say "Hello! What could I do for you, " & alphausername & "? "
set shouldseyi to "no"
end if
on error
say "Hello! What could I do for you?"
end try
tell application "SpeechRecognitionServer" to set theResponse to listen for {"Leave", "Hi", "Show me mr.Krol's website", "Report a bug", "Leave", "Open Mr.Krol's website", "Edmodo", "Open Edmodo", "You're Awesome", "IXL", "I found a bug", "What is your name", "What is the weather like", "thankyou", "Am I making good grades", "How are my grades", " Leave now", "Go to MMS website", "MMS", "SBISD", "Go to SBISD website", "Open IXL", "Show me the math textbook", "Math textbook", "Hello", "Thanks", "What's the weather like", "What is the weather like", "AlphaAssistant", "Good", "Thats Good", "Open iMovie", "Edit a video", "You're Evil", "You are evil", "Open Awesomeware", "Open AlphaTeam", "Open Minecraft", "goodbye", "Safari", "Open Safari", "You're Ugly", "You are ugly", "Where do you live", "Shutup", "Listen", "Listen to me", "What is my name", "Who am I", "Call me something else", "You're nice", "You are nice", "Okay", "Hows you're day", "Who are you", "Do you know Siri", "Testing 1234", "What is your favorite team", "SkyDoesMinecraft", "I love you", "Iron hand", "Do you know iron hand", "Should I wear shorts", "Test for connection", "What is the Temprature", "What version am I running", "Resset my volume", "You can talk now"} displaying "Version 1.0" with prompt ""
--Bug Report
if theResponse is "Report a bug" or theResponse is "I found a bug" then
say "You can send bug reports to us through our contact page. Would you like to go there?"
tell application "SpeechRecognitionServer" to set theResponse to listen for {"yes", "No"}
set openbugsite to "1"
if openbugsite is "1" and theResponse is "Yes" then
tell application "Safari"
say "Okay. I'll open up our contact page."
open location "http://alphateam2.weebly.com/contact.html"
set openbugsite to "0"
end tell
end if
end if
if theResponse is "No" then
say "Okay. I won't open the contact page."
end if
--Show Mr.Krol's Site
if theResponse is "Show me mr.Krol's website" or theResponse is "Open Mr.krol's website" then
say "i will show you Mister krol's website"
tell application "Safari"
open location "http://mms.springbranchisd.com/Staff/Teachers/Mathematics/JackKrol6thGrade/tabid /29065/Default.aspx"
end tell
end if
--Respond to "hello"
if theResponse is "Hi" or theResponse is "Hello" then
say "Alpha Assistant says hi"
end if
--Leave command
if theResponse is "Leave" or theResponse is "Leave now" or theResponse is "kill" or theResponse is "goodbye" then
say "okay. Bye"
tell application "SpeakableItems"
quit
end tell
exit repeat
tell me to quit
end if
--Edmodo
if theResponse is "Edmodo" then
tell application "Safari"
say "I'll open Edmodo."
open location "http://www.edmodo.com"
end tell
end if
--Respond to "You're Awesome" command
if theResponse is "You're awesome" then
say "Thanks! You're pretty cool yourself!"
end if
--Open Edmodo
if theResponse is "Open Edmodo" then
say "I'll open Edmodo"
tell application "Safari"
open location "http://www.edmodo.com"
end tell
end if
--Response to "what is your name command"
if theResponse is "What is your name" or theResponse is "Who are you" then
say "My name is Alpha Assistant."
end if
--Response to "what is the weather like command"
if theResponse is "What is the weather like" or theResponse is "What's the weather like" then
--this is the city code. Search the code for your city on http://weather.yahoo.com/
set CityCode to 2424766
--temperature format
set t_format to "F"
--voiceover format
set v_format to "S"
--say present condition
set a_format to "Y"
set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
--downloading the file using curl
set file_content to (do shell script "curl " & IURL)
--looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
--today conditions found
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
--looking for actual temperature temperature
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
if t_format is equal to "C" then
set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if
--looking for today forecast
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
--maximum and minimum temperatures found
set today_min_temp to word 9 of sub_2
set today_max_temp to word 12 of sub_2
if t_format is equal to "C" then
set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
end if
--looking for today forecast condition (a bit tricky)
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
--looking for tomorrow forecast
set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5
--maximum and minimum temperatures found
set tomorrow_min_temp to word 9 of sub_6
set tomorrow_max_temp to word 12 of sub_6
if t_format is equal to "C" then
set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
end if
--looking for tomorrow forecast condition (a bit tricky)
set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8
--VoiceOver Section
set myTime to time string of (current date)
set myParts to words of myTime
set mySpeak to (item 1 of myParts) & " " & (item 2 of myParts) & " "
if a_format is equal to "Y" then
say "Outside it is, " & actual_condition & ", and " & actual_temp & " degrees "
end if
if v_format is equal to "L" then
say "Today: " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees.
Tomorrow: " & tomorrow_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees"
else
say "Today: " & today_forecast & ", between " & today_min_temp & " , and " & today_max_temp & " degrees.
Tomorrow: " & tomorrow_forecast & ", between " & tomorrow_min_temp & " ,and " & tomorrow_max_temp & " degrees"
end if
end if
--Response to thankyou
if theResponse is "thankyou" or theResponse is "thanks" then
say "My pleasure"
end if
--Respond to "how are my grades"
if theResponse is "Am I making good grades" or theResponse is "How are my grades" then
say "I can not tell you your grades, but I can show you them on Skyward. Would you like me to go to Skyward?"
tell application "SpeechRecognitionServer" to set theResponse to listen for {"yes", "No"}
set openskyward to "1"
if openskyward is "1" and theResponse is "Yes" then
tell application "Safari"
say "Okay. I'll open Skyward. Please enter your Springbranch login info if you have not run the installer"
if doesexist is "true" then
set username2 to do shell script "cat ~/alphaassistantdata/username.txt "
else
set username2 to the text returned of (display dialog "Please enter your springbranch username." default answer "")
end if
if doesexist is "true" then
set password2 to do shell script "cat ~/alphaassistantdata/password.txt "
else
set password2 to the text returned of (display dialog "Please enter your springbranch password" default answer "")
end if
open location "https://skyward.springbranchisd.com/"
tell application "System Events"
delay 2
keystroke username2
end tell
tell application "System Events"
keystroke tab
end tell
tell application "System Events"
keystroke password2
end tell
tell application "System Events"
keystroke return
end tell
set openskyward to "3"
end tell
end if
end if
if theResponse is "No" and openskyward is "3" then
say "Okay. I won't open Skyward."
end if
-- go to MMS site
if theResponse is "MMS" or theResponse is "Go to MMS website" then
say "I'll go to the MMS Website."
tell application "Safari"
open location "http://mms.springbranchisd.com"
end tell
end if
--Go to SBISD site
if theResponse is "SBISD" or theResponse is "Go the the SBISD website" then
say "I'll go to the SBISD website"
tell application "Safari"
open location "http://www.springbranchisd.com"
end tell
end if
if theResponse is "IXL" or theResponse is "Open IXL" then
say "I'll open IXL"
tell application "Safari"
open location "www.ixl.com"
end tell
end if
if theResponse is "Show me the math textbook" or theResponse is "Math textbook" then
say "Okay, I'll show you the math textbook"
tell application "Safari"
open location "http://www.glencoe.com/ose/showbook.php"
end tell
end if
--AlphaAssistant
set alphaassistant to {"Thats me!", "Yes?", "AlphaAssistant here!"}
if theResponse is "AlphaAssistant" then
say some item of alphaassistant
end if
--Good
if theResponse is "good" or theResponse is "thats good" then
say "it is"
end if
if theResponse is "open iMovie" or theResponse is "Edit a video" then
tell application "iMovie"
end tell
end if
-- open alphateam
if theResponse is "open alphateam" then
say "I'll open Alpha Team's website"
tell application "Safari"
open location "http://www.alphateam2.weebly.com"
end tell
end if
-- Open Awesomeware
if theResponse is "Open Awesomeware" then
say "I'll open Awesomeware"
tell application "Safari"
open location "http://www.awesomeware.weebly.com"
end tell
end if
--random person like reposonses
if theResponse is "you're evil" or theResponse is "You are evil" then
say "what did I do?"
end if
if theResponse is "You're ugly" or theResponse is "You are ugly" then
say "Thats not nice…"
end if
if theResponse is "Where do you live" then
say "I live on your Mac, and lots of student's Macs"
end if
if theResponse is "Shutup" then
set currentVolume to output volume of (get volume settings)
set volume 0
say "Okay"
end if
if theResponse is "Listen to me" or theResponse is "Listen" then
say "I'm listening"
end if
if theResponse is "You're nice" or theResponse is "You are nice" then
say "Thanks!"
end if
if theResponse is "Okay" then
say "Okay"
end if
if theResponse is "How is you're day" or theResponse is "Hows you're day" then
say "It is great! Thanks for asking."
end if
if theResponse is "Do you know Siri" then
say "Yes…"
end if
if theResponse is "Testing 1234" then
say "Im am ready to assist"
end if
if theResponse is "I love you" then
say "Um… Thanks?"
end if
if theResponse is "iron hand" or theResponse is "Do you know iron hand" then
say "I don't like iron hand"
end if
-- Open Minecraft
if theResponse is "open Minecraft" and mcexists is "true" then
set mc1 to "true"
say "I'll open Minecraft"
tell application "Minecraft"
activate
end tell
else
if mc1 is "true" then
say "It looks like you don't have Minecraft"
end if
set mc1 to "False"
end if
-- Open Safari
if theResponse is "open Safari" or theResponse is "Safari" then
say "I'll open Safari"
tell application "Safari"
activate
end tell
end if
-- what is my name
if theResponse is "What is my name" or theResponse is "Who am I" then
try
say "You're name is " & alphausername & " "
on error
say "It appears that I don't know your name, Would you like to tell me?"
tell application "SpeechRecognitionServer" to set getnamea to listen for {"Yes", "No"}
if getnamea is "Yes" then
set alphausername to the text returned of (display dialog "What is you're name?" default answer "")
say "I'll call you " & alphausername & " "
do shell script "echo " & alphausername & " > $HOME/alphaassistantdata/name.txt"
end if
end try
end if
--Call me something else
if theResponse is "Call me something else" then
say "What would you like me to call you?"
set alphausername to the text returned of (display dialog "What would you like me to call you?" default answer "" buttons {"Okay"})
say "I'll call you " & alphausername & " "
do shell script "echo " & alphausername & " > $HOME/alphaassistantdata/name.txt"
end if
if theResponse is "what is your favorite team" then
say "My favorite team is Texas A&M"
end if
if theResponse is "SkyDoesMinecraft" then
say "I'll open Sky's website"
tell application "Safari"
open location "http://www.skydoesminecraft.com"
end tell
end if
--Should I wear
try
if theResponse is "should I wear shorts" then
set shouldwearing to "1"
if actual_temp < 70 then
say "no, today would not be a good day to wear shorts."
else
say "Yes, today would be a good day to wear shorts."
end if
end if
on error
if shouldwearing is "1" then
say "Please connect to the internet to use this feature"
end if
set shouldwearing to "0"
end try
--Test for connection
if theResponse is "Test for Connection" then
try
do shell script "ping -o www.apple.com"
set isonline to "true"
on error
set isonline to "false"
end try
if isonline is "true" then
say "I found a network"
else
say "I did not find a network"
end if
end if
if theResponse is "What is the Temprature" then
say "it is " & actual_temp & " degrees outside"
end if
if theResponse is "what version am I running" then
say "you are running Alpha Assistant version " & ver & " "
end if
if theResponse is "Reset my volume" or theResponse is "You can talk now" then
set volume currentVolume
say "Okay!"
end if
end repeat