Code suggestions

Hey!
I just finished an extensive ichat autoresponce applescript:

on removeText(ourText, findThis, replaceItWith)
	set newText to switchText of ourText from findThis to replaceItWith -- our call to the handler
	--> "To script or not to script, that is the question."  
	-- but we'll continue:
	set nextText to switchText of newText from " is the question" to " in doubt"
	--> "To script or not to script, that in doubt." 
	-- and then again:
	set lastText to switchText of nextText from "that" to "never"
	
	--> "To script or not to script, never in doubt."
	
end removeText

to switchText of theText from SearchString to ReplaceString
	set OldDelims to AppleScript's AppleScript's text item delimiters
	set AppleScript's AppleScript's text item delimiters to SearchString
	set newText to text items of theText
	set AppleScript's AppleScript's text item delimiters to ReplaceString
	set newText to newText as text
	set AppleScript's AppleScript's text item delimiters to OldDelims
	return newText
end switchText

on roundThis(n, numDecimals)
	set x to 10 ^ numDecimals
	(((n * x) + 0.5) div 1) / x
end roundThis

script Stopwatch
	property startTimes : {0, 0}
	property lapTimeList : {{1}, {2}}
	property ms : false --Attempts to use the GetMiliSec OSAX if it is installed.
	
	on startTimer(timerId) --Returns the timer ID for reference.
		try
			set currentTime to GetMilliSec
			set ms to true
		on error
			set currentTime to (time of (current date))
		end try
		repeat with thisTimerId in timerId as list
			set item thisTimerId of startTimes to currentTime
		end repeat
		return timerId
	end startTimer
	
	on getTime(timerId) --Returns the current elapsed time of the specified timer(s). Returned value is seconds as real.
		try
			set currentTime to GetMilliSec
			set ms to true
		on error
			set currentTime to (time of (current date))
		end try
		set thisTimersElapsedTime to {}
		repeat with thisTimerId in timerId as list
			if not ms then
				set thisTimersElapsedTime to thisTimersElapsedTime & currentTime - (item thisTimerId of startTimes)
			else
				set thisTimersElapsedTime to (thisTimersElapsedTime & currentTime - (item thisTimerId of startTimes)) / 1000
			end if
		end repeat
		try
			return thisTimersElapsedTime as integer
		on error
			return thisTimersElapsedTime
		end try
	end getTime
	
	on resetTimer(timerId) --Resets a lap timer.
		repeat with thisTimerId in timerId as list
			set item thisTimerId of lapTimeList to {}
		end repeat
		return timerId
	end resetTimer
	
end script

on kill(names)
	return ""
end kill

on weather(weatherconditionscontrol)
	--this is the city code. Search the code for your city on http://weather.yahoo.com/
	
	set CityCode to 11050
	
	--temperature format
	
	set t_format to "F"
	
	--voiceover format
	
	set v_format to "A"
	
	--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
	
	
	if weatherconditionscontrol is "today" then
		
		return "Today the forecast is " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees. " & "The current temperature is " & actual_temp & " degrees. "
		
	else if weatherconditionscontrol is "tommorow" then
		
		return "Tomorrow the forecast will be " & tomorrow_forecast & ". Temperature: between " & tomorrow_min_temp & " and " & tomorrow_max_temp & " degrees"
		
		
	end if
	
	
end weather

on getlasttweet(username)
	set myURL to "http://twitter.com/" & username
	set content to do shell script "curl " & myURL
	if content is not "<html><body>You are being <a href=\"http://twitter.com/suspended\">redirected</a>.</body></html>" and content does not contain "<h2>Sorry, that page doesn't exist!</h2>" and username is not "login" and username is not "home" then
		if content contains "<a class=\"entry-date\" rel=\"bookmark\" href=\"" then
			set text item delimiters to "<a class=\"entry-date\" rel=\"bookmark\" href=\""
			set content to text item 2 of content
			set text item delimiters to "\">"
			set content to text item 1 of content
			set lasttweet to do shell script "curl " & content & " | textutil -stdin -stdout -format html -convert txt -encoding UTF-8 "
			set text item delimiters to "Login Join Twitter!

"
			set lasttweet to text item 2 of lasttweet
			set text item delimiters to "
"
			set lasttweet to text item 1 of lasttweet
		else
			return ""
		end if
	else
		display dialog "This username does not exist or is not available."
	end if
end getlasttweet

using terms from application "iChat"
	
	on message received theMessage from theBuddy for theChat
		
		set startTime to missing value
		set endTime to missing value
		
		if theMessage is "current weather" then
			send weather("today") to theBuddy
			
		else if theMessage is "tommorow's weather" then
			send weather("tommorow") to theBuddy
			
		else if theMessage starts with "turn on bedlamp" then
			tell application "XTension"
				activate
				turnon "elijahroombedlamp"
			end tell
			send "Bedlamp has been turned on" to theBuddy
			
		else if theMessage is "turn off bedlamp" then
			tell application "XTension"
				activate
				turnoff "elijahroombedlamp"
			end tell
			send "Bedlamp has been turned off" to theBuddy
			
		else if theMessage is "turn on overheadlights" then
			tell application "XTension"
				activate
				turnon "elijahroomoverheadlights"
			end tell
			send "Overheadlights have been turned on" to theBuddy
			
		else if theMessage is "turn off overheadlights" then
			tell application "XTension"
				activate
				turnoff "elijahroomoverheadlights"
			end tell
			send "Overheadlights have been turned off" to theBuddy
			
		else if theMessage is "turn on fishtanklight" then
			tell application "XTension"
				activate
				turnon "elijahroomfishtanklight"
			end tell
			send "FishTankLight has been turned on" to theBuddy
			
		else if theMessage is "turn off fishtanklight" then
			tell application "XTension"
				activate
				turnoff "elijahroomfishtanklight"
			end tell
			send "FishTankLight has been turned off" to theBuddy
			
		else if theMessage is "feed fish" then
			do shell script "/Users/drummerboyx/Library/Scripts/arduino-serial -b 9600 -p /dev/tty.usbserial-A800ev0Z -s 1"
			send "Fish Have been feed " to theBuddy
			
		else if theMessage starts with "shell " then
			set shellCommand to removeText(theMessage, "shell ", "")
			set terminalResponce to do shell script shellCommand
			send terminalResponce to theBuddy
			
		else if theMessage is "CNN Update" then
			send "Loading..." to theBuddy
			send getlasttweet("cnn") to theBuddy
			
		else if theMessage is "Weather Update" then
			send "Loading..." to theBuddy
			send getlasttweet("weather") to theBuddy
			
		else if theMessage is "Project Jarvis update" then
			send "Loading..." to theBuddy
			send getlasttweet("cbarraford") to theBuddy
			
		else if theMessage is "the onion update" then
			send "Loading..." to theBuddy
			send getlasttweet("theonion") to theBuddy
			
		else if theMessage is "disable recognition" then
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.sound"
				reveal (first anchor of current pane whose name is "input")
			end tell
			
			tell application "System Events"
				
				launch
				tell process "System Preferences"
					set value of slider 1 of group 2 of tab group 1 of window 1 to 0
				end tell
			end tell
			tell application "System Preferences"
				quit
			end tell
			
			send "Speech recognition disabled" to theBuddy
			say "speech recognition disabled"
			beep 3
			
			
		else if theMessage is "enable recognition" then
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.sound"
				reveal (first anchor of current pane whose name is "input")
			end tell
			
			tell application "System Events"
				
				launch
				tell process "System Preferences"
					set value of slider 1 of group 2 of tab group 1 of window 1 to 1
				end tell
			end tell
			tell application "System Preferences"
				quit
			end tell
			
			send "Speech recognition enabled" to theBuddy
			say "speech recognition, enabled"
			beep 3
			
		else if theMessage is "disable speech" then
			say "speech, disabled"
			beep 3
			set volume output volume 0
			send "Speech disabled" to theBuddy
			
		else if theMessage is "enable speech" then
			set volume output volume 100
			beep 3
			say "speech, enabled"
			send "Speech enabled" to theBuddy
			
		else if theMessage is "goodnight" then
			startTimer(1) of Stopwatch --you can start multiple timers synchronously.
			beep 3
			say "speech, disabled"
			set volume output volume 0
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.sound"
				reveal (first anchor of current pane whose name is "input")
			end tell
			
			tell application "System Events"
				
				launch
				tell process "System Preferences"
					set value of slider 1 of group 2 of tab group 1 of window 1 to 0
				end tell
			end tell
			tell application "System Preferences"
				quit
			end tell
			send "Speech disabled, Goodnight Elijah!" to theBuddy
			tell application "XTension"
				turnoff "Elijah's Room"
			end tell
			
		else if theMessage is "goodmorning" then
			set volume output volume 100
			beep 3
			say "speech, enabled"
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.sound"
				reveal (first anchor of current pane whose name is "input")
			end tell
			
			tell application "System Events"
				
				launch
				tell process "System Preferences"
					set value of slider 1 of group 2 of tab group 1 of window 1 to 100
				end tell
			end tell
			tell application "System Preferences"
				quit
			end tell
			
			send "Good Morning Elijah! You've been sleeping for " & roundThis((Stopwatch's getTime(1)) / 3600, 3) & " hours." to theBuddy
			say "Good Morning Elijah!"
			
			Stopwatch's resetTimer(1)
			delay 1
			
		else if theMessage is "goodbye" then
			startTimer(2) of Stopwatch --you can start multiple timers synchronously.
			beep 3
			say "speech, disabled"
			set volume output volume 0
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.sound"
				reveal (first anchor of current pane whose name is "input")
			end tell
			
			tell application "System Events"
				
				launch
				tell process "System Preferences"
					set value of slider 1 of group 2 of tab group 1 of window 1 to 0
				end tell
			end tell
			tell application "System Preferences"
				quit
			end tell
			send "Speech disabled, See You Later Elijah!" to theBuddy
			tell application "XTension"
				turnoff "Elijah's Room"
			end tell
			
		else if theMessage is "I'm back" then
			set volume output volume 100
			beep 3
			say "speech, enabled"
			tell application "System Preferences"
				activate
				set current pane to pane "com.apple.preference.sound"
				reveal (first anchor of current pane whose name is "input")
			end tell
			
			tell application "System Events"
				
				launch
				tell process "System Preferences"
					set value of slider 1 of group 2 of tab group 1 of window 1 to 100
				end tell
			end tell
			tell application "System Preferences"
				quit
			end tell
			
			send "Hey Elijah!"
			say "Hey Elijah! You've been gone for " & roundThis((Stopwatch's getTime(2)) / 3600, 3) & " hours."
			
			Stopwatch's resetTimer(2)
			delay 1
			
			
		else if theMessage is "hey" then
			send "Hi!" to theBuddy
			
		else if theMessage is "hi" then
			send "Hey!" to theBuddy
			
		else if theMessage is "hello" then
			send "Hey!" to theBuddy
			
		else if theMessage is "thanks" then
			send "Your welcome sir." to theBuddy
			
		else if theMessage is "help" then
			send "speech, recognition, current weather, tommorow's weather, turn on, turn off, feed fish, update, goodbye, I'm back, goodmorning, goodnight, shell" to theBuddy
			
		else
			send "???" to theBuddy
		end if
	end message received
	
end using terms from

If any one has any suggestions on making the code better or even have ideas to make it do more things, that would be AWESOME!

Elijah