All pastes #583842 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-22 15:09 UTC
rendered paste body
-- Jason Reid's sysinfo script for Colloquy -- jasonreid.org --
--context menu and prefs added by Ray Nothnagel
--enhanced to work w/ intel macs and many features added, and some removed by KanadaKid
--source for additional commands, and output - modified aVirtualInferno.py by spaz (an X-Chat script)

property prefs : missing value
property prefsPath : missing value

using terms from application "Colloquy"
	on process incoming chat message chat
		if body of chat contains "waffle" then
			set msg to "likes waffles"
			tell view to send message msg with action tense
		end if
	end process incoming chat message
	
	on build contextual menu for item
		try
			--if theItem is "prefs:sysinfo" then
			my loadPrefs()
			tell prefs to set sm to getContextMenu()
			return {title:"Sysinfo settings", submenu:sm, |enabled|:true}
			--end if
		on error err
			return err
		end try
	end build contextual menu for item
	
	on handle clicked contextual menu item theItem within theParents
		try
			if theParents is {"Sysinfo settings"} then
				my loadPrefs()
				prefs's changekey(theItem)
				my savePrefs()
			end if
		on error err
			display dialog err
		end try
	end handle clicked contextual menu item
	
	on process user command c with arguments for view
		try
			if c is in {"sysinfo", "macinfo", "mac"} then
				my loadPrefs()
				tell application "Finder"
					
					set rollover to 2570
					set msg2 to "blah"
					
					set systemver to do shell script "system_profiler SPSoftwareDataType | grep -a 'System Version:'"
					set current_script_location to "system info"
					set rawModel to do shell script "sysctl -n hw.model"
					set hostname to do shell script "hostname -s"
					set cpus to do shell script "sysctl -n hw.ncpu"
					set cpufrequency to do shell script "sysctl -n hw.cpufrequency"
					
					set memtotal to do shell script "sysctl -n hw.memsize"
					set cpu to do shell script "machine"
					
					if systemver contains "10.3" then
						set l2cache to "test"
						set machineNamePretty to "Panther Box"
					else
						set l2cache to do shell script "sysctl -n hw.l2cachesize"
						set AppleScript's text item delimiters to ":"
						try
							set machineName to do shell script "system_profiler | grep -a 'Machine Name:'"
							set machineNamePretty to text item 2 of machineName
						on error
							set machineNamePretty to "Apple Development Platform"
						end try
					end if
					set cpuspeedpretty to ""
					
					set systemvertemp to text item 2 of systemver
					set AppleScript's text item delimiters to "("
					set systemvernum to text item 1 of systemvertemp
					set buildtemp to text item 2 of systemvertemp
					set AppleScript's text item delimiters to ")"
					set buildnum to text item 1 of buildtemp
					
					--Kernel Info
					set AppleScript's text item delimiters to "="
					set kerninfo to do shell script "sysctl kern.osrelease"
					set kernelnum to text item 2 of kerninfo
					set AppleScript's text item delimiters to "."
					set kernelbuildnum to text item 2 of kernelnum
					set osnum to text item 1 of kernelnum
					set osnum to osnum - 4
					
					set current_script_location to "processor info"
					--Keeping Intel stuff away from PPC macs
					if cpu is in {"i486", "pentium4"} then
						set AppleScript's text item delimiters to ":"
						set cputype to do shell script "sysctl machdep.cpu.brand_string"
						set cputypepretty to text item 2 of cputype
						
						-- Remove "(R)" from the Cpu Type Info					
						repeat
							if cputypepretty contains "(R)" then
								set AppleScript's text item delimiters to "(R)"
								set cpu1 to text item 1 of cputypepretty
								set cpu2 to text items 2 thru end of cputypepretty
								set cputypepretty to cpu1 & cpu2
							else
								exit repeat
							end if
						end repeat
						
						-- Remove "Processor" from the Cpu Type Info					
						repeat
							if cputypepretty contains "Processor" then
								set AppleScript's text item delimiters to "Processor"
								set cpu1 to text item 1 of cputypepretty
								set cpu2 to text items 2 thru end of cputypepretty
								set cputypepretty to cpu1 & cpu2
							else
								exit repeat
							end if
						end repeat
						
						-- Remove "Dual Core" from the Cpu Type Info					
						repeat
							if cputypepretty contains "Dual Core" then
								set AppleScript's text item delimiters to "Dual Core"
								set cpu1 to text item 1 of cputypepretty
								set cpu2 to text items 2 thru end of cputypepretty
								set cputypepretty to cpu1 & cpu2
							else
								exit repeat
							end if
						end repeat
						
						-- Remove "CPU" from the Cpu Type Info					
						repeat
							if cputypepretty contains "CPU" then
								set AppleScript's text item delimiters to "CPU"
								set cpu1 to text item 1 of cputypepretty
								set cpu2 to text items 2 thru end of cputypepretty
								set cputypepretty to cpu1 & cpu2
							else
								exit repeat
							end if
						end repeat
						
						-- Remove "(TM)" from the Cpu Type Info					
						repeat
							if cputypepretty contains "(TM)" then
								set AppleScript's text item delimiters to "(TM)"
								set cpu1 to text item 1 of cputypepretty
								set cpu2 to text items 2 thru end of cputypepretty
								set cputypepretty to cpu1 & cpu2
							else
								exit repeat
							end if
						end repeat
						
						set sse3check to do shell script "sysctl hw.optional.sse3"
						set intelcore to "no"
						set paecheck to do shell script "sysctl machdep.cpu.features"
						set xdcheck to do shell script "sysctl machdep.cpu.extfeatures"
						
						set AppleScript's text item delimiters to ":"
						set htchecktemp to do shell script "sysctl machdep.cpu.logical_per_package"
						set htcheck to text item 2 of htchecktemp
						set corechecktemp to do shell script "sysctl machdep.cpu.cores_per_package"
						set corecheck to text item 2 of corechecktemp
						set ncputemp to do shell script "sysctl hw.ncpu"
						set ncpu to text item 2 of ncputemp
						
						set cpumultiplier to ""
						
						
						set ctype to do shell script "sysctl hw.cputype"
						set csubtype to do shell script "sysctl hw.cpusubtype"
						set brandstring to do shell script "sysctl machdep.cpu.brand_string"
						
						if brandstring contains "@" then
							set AppleScript's text item delimiters to ":"
							set bstmp to text item 2 of brandstring
							set AppleScript's text item delimiters to "        "
							set bstmp to text item 2 of bstmp
							set AppleScript's text item delimiters to " @ "
							set cpumodelnum to text item 1 of bstmp
							set cpumodelspeed to text item 2 of bstmp
							set AppleScript's text item delimiters to ""
							if ctype contains "7" then
								if csubtype contains "4" then
									if ncpu contains "2" then
										if corecheck contains "1" then
											set cpumultiplier to "2 x "
										end if
									else if ncpu contains "4" then
										if corecheck contains "2" then
											set cpumultiplier to "2 x "
										end if
									else if ncpu contains "8" then
										if corecheck contains "4" then
											set cpumultiplier to "4 x "
										end if
									end if
									
									if corecheck contains "1" then
										set cputypepretty to "Intel Core Solo " & cpumodelnum
									else if corecheck contains "2" then
										if brandstring contains "Genuine" then
											set cputypepretty to "Intel Core Duo " & cpumodelnum
										else if brandstring contains "Core(TM)2" then
											set cputypepretty to "Intel Core 2 Duo " & cpumodelnum
										else if brandstring contains "Xeon" then
											set cputypepretty to "Intel Xeon " & cpumodelnum
										end if
									end if
									
									set cputypepretty to cputypepretty & cpumodelspeed
									
								end if
							end if
						end if
					else
						set current_script_location to "ppc info"
						set cpumultiplier to ""
						set AppleScript's text item delimiters to ":"
						set corechecktemp to do shell script "sysctl hw.ncpu"
						set corecheck to text item 2 of corechecktemp
						set altivectemp to do shell script "sysctl hw.optional.altivec"
						set altiveccheck to text item 2 of altivectemp
					end if
					
					--np101137 Genuine Intel fix
					if cputypepretty contains "Genuine Intel" then
						set AppleScript's text item delimiters to "Genuine Intel"
						set cputypepretty to "Mobile Intel Pentium 4" & text item 2 of cputypepretty
					end if
					
					--FSB Code
					set current_script_location to "FSB detection"
					set AppleScript's text item delimiters to ":"
					set fsbtemp to do shell script "sysctl hw.busfrequency"
					set fsb to text item 2 of fsbtemp
					set fsb to round (fsb / 1000000) rounding down
					
					set current_script_location to "speedit code"
					if systemver contains "10.4" then
						set speeditcheck to do shell script "sysctl -a kern.cpu_currentfreq"
						if speeditcheck contains ":" then
							set AppleScript's text item delimiters to ":"
							set currentfreqtmp to do shell script "sysctl kern.cpu_currentfreq"
							set currentfreq to text item 2 of currentfreqtmp
						end if
					else
						set speeditcheck to ""
					end if
					
					set current_script_location to "graphics info"
					
					if prefs's getKey("Display Info Override") then
						set graphicspretty to prefs's getKey("Override Value")
					else
						set AppleScript's text item delimiters to ":"
						set infocheck to do shell script "system_profiler SPDisplaysDataType"
						if infocheck contains "Chipset" then
							set AppleScript's text item delimiters to ":"
							set graphicscard to do shell script "system_profiler SPDisplaysDataType | grep -a 'Chipset Model:'"
							set graphicspretty to text item 2 of graphicscard
						else
							set AppleScript's text item delimiters to ":"
							set graphicscard to do shell script "system_profiler SPDisplaysDataType | grep -a 'Vendor:'"
							set graphicsprettytmp to text item 2 of graphicscard
							set AppleScript's text item delimiters to "("
							set graphicspretty to text item 1 of graphicsprettytmp
						end if
					end if
					
					if graphicspretty contains "ATY" then
						set graphicstemp to text 12 thru end of graphicspretty
						set graphicspretty to "ATI Radeon " & graphicstemp
					end if
					set vram to do shell script "system_profiler SPDisplaysDataType | grep -a 'VRAM (Total):'"
					set vrampretty to text 21 thru end of vram
					set qecheck to do shell script "system_profiler SPDisplaysDataType | grep -a 'Quartz Extreme:'"
					set cicheck to ""
					set hacheck to ""
					set cicheck to do shell script "system_profiler SPDisplaysDataType | grep -a 'Core Image:'"
					set displaycheck to do shell script "system_profiler SPDisplaysDataType | grep -a 'Resolution:' -c"
					set resolution to do shell script "system_profiler SPDisplaysDataType | grep -a 'Resolution:'"
					set displaydata to do shell script "system_profiler SPDisplaysDataType"
					if displaycheck contains "1" then
						set AppleScript's text item delimiters to ":"
						set respretty to text item 2 of resolution
					else
						set AppleScript's text item delimiters to "Resolution:"
						set respretty to text item 2 of resolution
						set respretty2 to text item 3 of resolution
						repeat
							if respretty2 contains " " then
								set AppleScript's text item delimiters to " "
								set res1 to text item 1 of respretty2
								set res2 to text items 2 thru end of respretty2
								set respretty2 to res1 & res2
							else
								exit repeat
							end if
						end repeat
					end if
					
					--remove spaces from resolution output
					repeat
						if respretty contains " " then
							set AppleScript's text item delimiters to " "
							set res1 to text item 1 of respretty
							set res2 to text items 2 thru end of respretty
							set respretty to res1 & res2
						else
							exit repeat
						end if
					end repeat
					
					--Graphics Driver ID
					set gfxdrivertmp to do shell script "ls /System/Library/Extensions/"
					if cpu is in {"i486", "pentium4"} then
						if gfxdrivertmp contains "NVidia.kext" then
							set gfxdriver to "MacVidia"
						else if gfxdrivertmp contains "Titan.kext" then
							set gfxdriver to "Titan"
						else if gfxdrivertmp contains "Natit.kext" then
							set gfxdriver to "Natit"
						else if gfxdrivertmp contains "callisto.kext" then
							set gfxdriver to "Callisto"
						else
							set gfxdriver to "Stock"
						end if
					end if
					
					--Battery Stuff
					set current_script_location to "battery info"
					set powerdata to ""
					ignoring application responses
						do shell script "ioreg -l -w 0 | grep -m 1 BatteryInfo > /tmp/ioreg.txt"
					end ignoring
					set powerdata to do shell script "cat /tmp/ioreg.txt"
					if powerdata contains "BatteryInfo" then
						if powerdata contains "IOBatteryInfo" then
							set AppleScript's text item delimiters to "="
							set temp to text item 3 of powerdata
							set temp2 to text item 5 of powerdata
							set AppleScript's text item delimiters to ","
							set theMax to text item 1 of temp
							set theCur to text item 1 of temp2
						else if powerdata contains "LegacyBatteryInfo" then
							set AppleScript's text item delimiters to "="
							set temp to text item 3 of powerdata
							set temp2 to text item 6 of powerdata
							set AppleScript's text item delimiters to ","
							set theMax to text item 1 of temp
							set theCur to text item 1 of temp2
						end if
					end if
					
					--Virtual Mem Stuff
					set current_script_location to "vram info"
					set AppleScript's text item delimiters to " "
					set temp to do shell script "sysctl vm.swapusage"
					set vmtotal to text item 4 of temp
					set vmused to text item 8 of temp
					
					--Used Ram Stuff
					
					set current_script_location to "ram info"
					set AppleScript's text item delimiters to ":"
					set temp to do shell script "vm_stat | grep -m 1 free"
					set tempf to text item 2 of temp
					set temp to do shell script "vm_stat | grep -m 1 active"
					set tempa to text item 2 of temp
					set temp to do shell script "vm_stat | grep -m 1 inactive"
					set tempi to text item 2 of temp
					set temp to do shell script "vm_stat | grep -m 1 wired"
					set tempw to text item 2 of temp
					set AppleScript's text item delimiters to "."
					set tempf to text item 1 of tempf
					set tempa to text item 1 of tempa
					set tempi to text item 1 of tempi
					set tempw to text item 1 of tempw
					set memtotal2 to (tempf + tempa + tempi + tempw) * 4096 / 1048576
					set freemem to (tempf + tempi) * 4096 / 1048576
					set usedmem to round (memtotal2 - freemem) rounding down
					--set usedmem to (round (usedmem * 100)) / 100
					set mempercent to round ((usedmem / memtotal2) * 100) rounding down
					set activebar to round (mempercent / 10) rounding up
					set inactivebar to 10 - activebar
					
					set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
					set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
					set rambar to ""
					repeat activebar times
						if colorone is not equal to colortwo then
							set rambar to rambar & "<span style=\"" & colorone & "\">&#x2759</span>"
						else
							set rambar to rambar & "<span style=\"color:red\">&#x2759</span>"
						end if
					end repeat
					repeat inactivebar times
						set rambar to rambar & "<span style=\"" & colortwo & "\">&#x2759</span>"
						--set rambar to rambar & "<span style=\"color:grey\">/</span>"
					end repeat
					
					--Audio info
					
					set kextstat to do shell script "kextstat"
					if kextstat contains "IOAudioFamily" then
						if kextstat contains "AC97" then
							set audio to "AC'97"
						else if kextstat contains "AppleHDA" then
							set audio to "Apple HDA"
						else if kextstat contains "AppleAzaliaAudio" then
							set audio to "Azalia"
						else
							set audio to "Unknown"
						end if
					else
						set audio to "None"
					end if
					
					
					--Hard disk info
					set current_script_location to "hd info"
					set myList to list disks
					set allFree to 0
					set allSpace to 0
					repeat with i in myList
						set diskName to (i as string)
						try
							set freespace to round (the (free space of disk diskName) / 1024 / 1024)
							set totalspace to round (the (capacity of disk diskName) / 1024 / 1024)
							set allFree to allFree + freespace
							set allSpace to allSpace + totalspace
						end try
					end repeat
					set allUsed to allSpace - allFree
					set allUsed to allUsed / 1024
					set allUsed to (round allUsed * 100) / 100
					set allSpace to allSpace / 1024
					set allSpace to (round allSpace * 100) / 100
					if allUsed is greater than 1024 then
						set allUsed to allUsed / 1024
						set allUsed to (round allUsed * 100) / 100
						set usedunit to "TB"
					else
						set usedunit to "GB"
					end if
					if allSpace is greater than 1024 then
						set allSpace to allSpace / 1024
						set allSpace to (round allSpace * 100) / 100
						set spaceunit to "TB"
					else
						set spaceunit to "GB"
					end if
					
					--username
					set current_script_location to "username info"
					set whoAmI to do shell script "whoami"
					
					--Network info
					set netdisabled to true
					if netdisabled is false then
						set current_script_location to "network info"
						set netadapter to prefs's getKey("Network Interface")
						set temp to do shell script "netstat -I " & netadapter & " -b | grep en0 -m 1"
						set amount_in to word 15 of temp
						set amount_out to word 18 of temp
						set amount_in to amount_in / 1024
						set amount_out to amount_out / 1024
						set in_measure to "K"
						set out_measure to "K"
						if amount_in is greater than 1024 then
							set amount_in to amount_in / 1024
							set in_measure to "M"
							if amount_in is greater than 1024 then
								set amount_in to amount_in / 1024
								set in_measure to "G"
								if amount_in is greater than 1024 then
									set amount_in to amount_in / 1024
									set in_measure to "T"
								end if
							end if
						end if
						if amount_out is greater than 1024 then
							set amount_out to amount_out / 1024
							set out_measure to "M"
							if amount_out is greater than 1024 then
								set amount_out to amount_out / 1024
								set out_measure to "G"
								if amount_out is greater than 1024 then
									set amount_out to amount_out / 1024
									set out_measure to "T"
								end if
							end if
						end if
						
						set AppleScript's text item delimiters to " "
						set amount_in to ((round (amount_in * 100) rounding down) / 100)
						set amount_out to ((round (amount_out * 100) rounding down) / 100)
					end if
					
					--Number of processes
					set current_script_location to "process info"
					set procnumber to do shell script "ps -ax | wc -l"
					
					--Uptime
					set current_script_location to "uptime info"
					set uptime to do shell script "uptime | awk '{sub(/.*up[ ]+/,\"\",$0) ; sub(/,[ ]+[0-9]+ user.*/,\"\",$0);sub(/,/,\"\",$0) ;print $0}'"
					
					--Timestamp
					set current_script_location to "timestamp"
					set datetmp to do shell script "date"
					set AppleScript's text item delimiters to " "
					set date2 to text item 2 of datetmp
					set date3 to text item 3 of datetmp
					set date4 to text item 4 of datetmp
					set date5 to text item 5 of datetmp
					set date6 to text item 6 of datetmp
					if date4 contains ":" then
						set AppleScript's text item delimiters to ":"
						set time1 to text item 1 of date4
						set time2 to text item 2 of date4
						set timetmp to time1 & ":" & time2
						set dateoutput to " (" & date2 & "-" & date3 & "-" & date6 & " : " & timetmp & ")"
					else
						set date7 to text item 7 of datetmp
						set AppleScript's text item delimiters to ":"
						set time1 to text item 1 of date5
						set time2 to text item 2 of date5
						set timetmp to time1 & ":" & time2
						set dateoutput to " (" & date2 & "-" & date4 & "-" & date7 & " : " & timetmp & ")"
					end if
					
					--Colloquy Ver
					set current_script_location to "colloquy ver info"
					set collover to version of application "Colloquy"
					set collopath to POSIX path of (path to application "Colloquy")
					set collotemp to do shell script "cat " & collopath & "/Contents/Info.plist | grep CFBundleVersion -A 1"
					set AppleScript's text item delimiters to "<string>"
					set collotemp to text item 2 of collotemp
					set AppleScript's text item delimiters to "</string>"
					set collobuild to text item 1 of collotemp
				end tell
				
				set current_script_location to "color settings"
				set stealthmode to prefs's getKey("Stealth Mode")
				if stealthmode then
					set colorone to "color:none"
					set colortwo to "color:none"
					set labelstyle to "color:navy;font-weight:bold"
					set valuestyle to ""
				else
					set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
					set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
					set labelstyle to prefs's getKey("Label Style")
					set valuestyle to prefs's getKey("Value Style")
				end if
				
				set osbuildpref to prefs's getKey("--Build Number")
				set timestamppref to prefs's getKey("Timestamp")
				set displaykextpref to prefs's getKey("Display Kext Info")
				
				set current_script_location to "prefs"
				set tempprefs to prefs
				if arguments is not "" then
					
					--New preferences option (borrowed from Colloquy's itunes script)
					if first word of arguments is "prefs" then
						tell view to add event message "MOVED! Control-click (or right-click) the channel window for SysInfo Prefs" with name "sysinfo"
						return true
					end if
					
					set current_script_location to "update"
					if first word of arguments is "update" then
						try
							do shell script "curl -s -B http://www.personal.psu.edu/sal238/scripts/Colloquy/sysinfo.scpt.zip -o /tmp/sysinfo.scpt.zip"
							do shell script "zip -r -j ~/Library/Application\\ Support/Colloquy/Plugins/backup.zip ~/Library/Application\\ Support/Colloquy/Plugins/sysinfo.scpt"
							try
								do shell script "zip -r -j ~/Library/Application\\ Support/Colloquy/Plugins/prefbackup.zip ~/Library/Preferences/Colloquy\\ Prefs\\ -\\ Sysinfo\\ KK"
							end try
							do shell script "unzip -o -qq /tmp/sysinfo.scpt.zip -d ~/Library/Application\\ Support/Colloquy/Plugins/"
							do shell script "rm /tmp/sysinfo.scpt.zip"
							try
								do shell script "rm ~/Library/Preferences/Colloquy\\ Prefs\\ -\\ Sysinfo\\ KK"
							end try
							tell view to add event message "Update Successful! To load new version type /reload plugins" with name "sysinfo"
							my loadPrefs()
						on error err
							do shell script "rm /tmp/sysinfo.scpt.zip"
							tell view to add event message "Update Failed:" & err with name "sysinfo"
							
						end try
						return true
					end if
					
					
					--Added help to display added commands/syntax
					set current_script_location to "help"
					if first word of arguments is "help" then
						tell view to add event message "<b>Here is a list of commands:</b>" with name "sysinfo"
						tell view to add event message "     /sysinfo - displays all (selected) system info" with name "sysinfo"
						tell view to add event message "     /sysinfo (value name) - display certain sysinfo values" with name "sysinfo"
						tell view to add event message "     Example: /sysinfo cpu ram display uptime battery" with name "sysinfo"
						tell view to add event message "     /azureus or /azfull- show Azureus speeds and downloads" with name "sysinfo"
						tell view to add event message "     /az - show only Azureus speeds" with name "sysinfo"
						tell view to add event message "     /xbmc - show what is playing in XBMC" with name "sysinfo"
						tell view to add event message "     /weather (zip) - show weather at specified zip" with name "sysinfo"
						tell view to add event message "     /weatherca (city province/country) - show weather at given city" with name "sysinfo"
						tell view to add event message "     /quicktime or /qt - show what is playing in Quicktime" with name "sysinfo"
						tell view to add event message "     /videolan or /vlc - show what is playing in VLC Player" with name "sysinfo"
						tell view to add event message "     /mactunes - show what is playing in iTunes" with name "sysinfo"
						tell view to add event message "     /exec (command) - execute terminal command, output to self" with name "sysinfo"
						tell view to add event message "     /execo (command) - execute terminal command, output to channel" with name "sysinfo"
						tell view to add event message "     /sysupdate or /macupdate - updates (and deletes prefs)" with name "sysinfo"
						tell view to add event message "     /sysinfo help - display this help message" with name "sysinfo"
						
						return true
					end if
					repeat with k in theKeys of tempprefs
						if class of value of k is boolean then
							set value of k to false
							repeat with arg in words of arguments
								if label of k contains arg then
									set value of k to true
									exit repeat
								end if
							end repeat
						end if
					end repeat
					
				end if
				
				if stealthmode then
					set msg to "<span style=\"" & valuestyle & "\">" & "<span style=\"color:navy\">"
				else
					set msg to "<span style=\"" & valuestyle & "\">" & "<span style=\"" & colorone & "\">"
				end if
				
				set current_script_location to "intel mac code check"
				--Intel Mac Code
				if cpu is in {"i486", "pentium4"} then
					if machineNamePretty contains "Apple Development Platform" then
						set machineNamePretty to prefs's getKey("Replacement Name")
					else if machineNamePretty contains "jMac" then
						set machineNamePretty to prefs's getKey("Replacement Name")
					else if rawModel is in {"ACPI", "ADP2,1"} then
						set machineNamePretty to prefs's getKey("Replacement Name")
					end if
					set msg to msg & machineNamePretty & " "
				else
					set current_script_location to "ppc model info"
					if rawModel is "AAPL,7300" then
						set msg to msg & "Powermac 7200/7300"
					else if rawModel is "AAPL,7500" then
						set msg to msg & "Powermac 7500/7600"
					else if rawModel is "AAPL,8500" then
						set msg to msg & "Powermac 8500/8600"
					else if rawModel is "AAPL,9500" then
						set msg to msg & "Powermac 9500/9600"
					else if rawModel is "AAPL,ShinerESB" then
						set msg to msg & "Apple Network Server"
					else if rawModel is "AAPL,e407" then
						set msg to msg & "Alchemy (family)"
					else if rawModel is "AAPL,e411" then
						set msg to msg & "Gazelle (family)"
					else if rawModel is "Apple,e826" then
						set msg to msg & "Tanzania (family)"
						--Powermac
					else if rawModel is "PowerMac1,1" then
						set msg to msg & "PowerMac G3 B/W"
					else if rawModel is "AAPL,Gossamer" then
						set msg to msg & "PowerMac G3 Beige Rev.A"
					else if rawModel is "AAPL,PowerMac G3" then
						set msg to msg & "PowerMac G3 Beige Rev.B"
					else if rawModel is "PowerMac1,1" then
						set msg to msg & "PowerMac G3 B/W Rev1"
					else if rawModel is "PowerMac1,2" then
						set msg to msg & "PowerMac G4 Yikes"
					else if rawModel is "PowerMac3,1" then
						set msg to msg & "PowerMac G4 AGP"
					else if rawModel is "PowerMac3,3" then
						set msg to msg & "PowerMac G4 GBE"
					else if rawModel is "PowerMac3,4" then
						set msg to msg & "PowerMac G4 DA"
					else if rawModel is "PowerMac5,1" then
						set msg to msg & "PowerMac Cube"
					else if rawModel is "PowerMac3,5" then
						set msg to msg & "PowerMac G4 QS"
					else if rawModel is "PowerMac3,6" then
						set msg to msg & "PowerMac G4 MDD"
					else if rawModel is "PowerMac7,2" then
						set msg to msg & "PowerMac G5 (June 2004)"
					else if rawModel is "PowerMac7,3" then
						set msg to msg & "PowerMac G5 (Early 2005)"
					else if rawModel is "PowerMac9,1" then
						set msg to msg & "PowerMac G5 (Late 2004)"
					else if rawModel is "PowerMac11,2" then
						set msg to msg & "PowerMac G5 DualCore (Late 2005)"
						-- PowerBooks
					else if rawModel is "AAPL,3400/2400" then
						set msg to msg & "Powerbook 2400/3400"
					else if rawModel is "AAPL,3500" then
						set msg to msg & "Powerbook G3 (3500)"
					else if rawModel is "AAPL,PowerBook1998" then
						set msg to msg & "PowerBook G3 Wallstreet"
					else if rawModel is "PowerBook1,1" then
						set msg to msg & "PowerBook G3 Lombard"
					else if rawModel is "PowerBook3,1" then
						set msg to msg & "PowerBook G3 Pismo"
					else if rawModel is "PowerBook3,2" then
						set msg to msg & "PowerBook G4 Ti Rev1"
					else if rawModel is "PowerBook3,3" then
						set msg to msg & "PowerBook G4 Ti Rev2"
					else if rawModel is "PowerBook3,4" then
						set msg to msg & "PowerBook G4 Ti Rev3"
					else if rawModel is "PowerBook3,5" then
						set msg to msg & "PowerBook G4 Ti Rev4"
					else if rawModel is "PowerBook5,1" then
						set msg to msg & "PowerBook G4 Al 17in"
					else if rawModel is "PowerBook5,2" then
						set msg to msg & "PowerBook G4 Al 15in"
					else if rawModel is "PowerBook5,3" then
						set msg to msg & "PowerBook G4 Al 17in"
					else if rawModel is "PowerBook5,4" then
						set msg to msg & "PowerBook G4 Al 15in Rev2"
					else if rawModel is "PowerBook5,5" then
						set msg to msg & "PowerBook G4 Al 17in Rev2"
					else if rawModel is "PowerBook6,1" then
						set msg to msg & "PowerBook G4 Al 12in"
					else if rawModel is "PowerBook6,2" then
						set msg to msg & "PowerBook G4 Al 12in DVI"
					else if rawModel is "PowerBook6,4" then
						set msg to msg & "Powerbook G4 Al 12in (April 2004)"
					else if rawModel is "PowerBook6,8" then
						set msg to msg & "Powerbook G4 Al 12in (Jan 2005)"
					else if rawModel is "PowerBook5,6" then
						set msg to msg & "Powerbook G4 Al 15in (Jan 2005)"
					else if rawModel is "PowerBook5,7" then
						set msg to msg & "Powerbook G4 Al 17in (Jan 2005)"
					else if rawModel is "PowerBook5,8" then
						set msg to msg & "Powerbook G4 Al 15in (Oct 2005)"
					else if rawModel is "PowerBook5,9" then
						set msg to msg & "Powerbook G4 Al 17in (Oct 2005)"
						-- iMac
					else if rawModel is "iMac,1" then
						set msg to msg & "iMac G3 Rev1"
					else if rawModel is "PowerMac2,1" then
						set msg to msg & "iMac 1999 (Slot-Loading)"
					else if rawModel is "PowerMac2,2" then
						set msg to msg & "iMac (Summer 2000)"
					else if rawModel is "PowerMac4,1" then
						set msg to msg & "iMac G3 2001"
					else if rawModel is "PowerMac4,2" then
						set msg to msg & "iMac G4 FP Rev1"
					else if rawModel is "PowerMac4,3" then
						set msg to msg & "iMac G4 FP Rev1"
					else if rawModel is "PowerMac4,5" then
						set msg to msg & "iMac G4 FP Rev1"
					else if rawModel is "PowerMac6,1" then
						set msg to msg & "iMac G4 FP Rev2"
					else if rawModel is "PowerMac6,3" then
						set msg to msg & "iMac G4 FP 20\""
					else if rawModel is "PowerMac8,1" then
						set msg to msg & "iMac G5"
					else if rawModel is "PowerMac8,2" then
						set msg to msg & "iMac G5 Rev B."
					else if rawModel is "PowerMac12,1" then
						set msg to msg & "iMac G5 (Late 2005)"
						--Mac mini
					else if rawModel is "PowerMac10,1" then
						set msg to msg & "Mac mini"
					else if rawModel is "PowerMac10,2" then
						set msg to msg & "Mac mini (Late 2005)"
						-- eMac
					else if rawModel is "PowerMac4,4" then
						set msg to msg & "eMac G4 Rev1"
					else if rawModel is "PowerMac6,4" then
						set msg to msg & "eMac G4 Rev2"
						-- iBook
					else if rawModel is "PowerBook2,2" then
						set msg to msg & "iBook G3 Rev3"
					else if rawModel is "PowerBook4,1" then
						set msg to msg & "iBook G3 Rev4"
					else if rawModel is "PowerBook4,2" then
						set msg to msg & "iBook G3 Rev5"
					else if rawModel is "PowerBook4,3" then
						set msg to msg & "iBook G3 Rev6"
					else if rawModel is "PowerBook6,3" then
						set msg to msg & "iBook G4"
					else if rawModel is "PowerBook6,5" then
						set msg to msg & "iBook G4 Rev2"
					else if rawModel is "PowerBook6,7" then
						set msg to msg & "iBook G4 (Mid 2005)"
					else
						set msg to msg & "Unknown"
					end if
				end if
				set msg to msg & "</span> " & "</span> "
				set current_script_location to "name output"
				if tempprefs's getKey("Name") then
					set msg to msg & "<span style=\"" & labelstyle & "\">\"</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & hostname & "</span></span><span style=\"" & labelstyle & "\">\"</span> "
				end if
				
				if tempprefs's getKey("CPU Type") then
					set current_script_location to "cpu output"
					set msg to msg & "<span style=\"" & labelstyle & "\">CPU: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">"
					set msg to msg & cpumultiplier
					if cpu is in {"i486", "pentium4"} then
						set msg to msg & cputypepretty & " </span></span>"
					else
						set AppleScript's text item delimiters to "ppc"
						set cpupretty to text item 2 of cpu
						set msg to msg & "PowerPC " & cpupretty & "</span></span> "
						if cpu is in {"ppc750", "ppc750fx"} then
							set msg to msg & "<span style=\"" & valuestyle & "\">(<span style=\"" & colorone & "\">G3</span>)</span>"
						else if cpu is in {"ppc7400", "ppc7410", "ppc7447", "ppc7450", "ppc7451", "ppc7455"} then
							set msg to msg & "<span style=\"" & valuestyle & "\">(<span style=\"" & colorone & "\">G4</span>)</span>"
						else if cpu is in {"ppc970", "ppc970fx"} then
							set msg to msg & "<span style=\"" & valuestyle & "\">(<span style=\"" & colorone & "\">G5</span>)</span>"
						end if
					end if
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("CPU Frequency") then
					set current_script_location to "cpu freq output"
					if tempprefs's getKey("CPU Type") then
						set msg to msg & " "
					else
						set msg to msg & "<span style=\"" & labelstyle & "\">CPU Speed:</span> "
					end if
					if speeditcheck contains ":" then
						set curfreq to currentfreq / 1000
						set msg to msg & "<span style=\"" & labelstyle & "\">" & "@ " & "</span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & (round curfreq * 100) / 100 & "GHz </span></span>"
					else
						set msg to msg & "<span style=\"" & valuestyle & "\">" & cpuspeedpretty & " </span>"
						if cpufrequency / 1000000 &#8805; 990 then
							set cpufreq to (cpufrequency / 100000000) / 10
							set msg to msg & "<span style=\"" & labelstyle & "\">" & "@ " & "</span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & (round cpufreq * 100) / 100 & "GHz </span></span>"
						else
							set cpufreq to (cpufrequency / 1000000)
							set msg to msg & "<span style=\"" & labelstyle & "\">" & "@ " & "</span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & (round cpufreq * 100) / 100 & "MHz </span></span>"
						end if
					end if
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("CPU Stats") then
					set current_script_location to "cpu stat output"
					set msg to msg & "<span style=\"" & valuestyle & "\">[<span style=\"" & colorone & "\">"
					--more keeping Intel stuff from PPC processors
					if cpu is in {"i486", "pentium4"} then
						if sse3check contains 0 then
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "SSE2</span>"
						else
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "SSE3</span>"
						end if
						if paecheck contains "PAE" then
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "/PAE</span>"
						end if
						if xdcheck contains "XD" then
							if cputypepretty contains "AMD" then
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/NX</span>"
							else
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/XD</span>"
							end if
						end if
						if paecheck contains "MMX" then
							if cputypepretty contains "AMD" then
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/3DNow!</span>"
							end if
						end if
						if paecheck contains "EST" then
							if cputypepretty contains "AMD" then
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/PowerNow!</span>"
							else
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/EST</span>"
							end if
						end if
						if paecheck contains "VMX" then
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "/VMX</span>"
						end if
						if xdcheck contains "EM64T" then
							if cputypepretty contains "AMD" then
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/AMD64</span>"
							else
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/EM64T</span>"
							end if
						end if
						if htcheck contains 2 then
							if corecheck contains 0 then
								if cputypepretty contains "AMD" then
									set msg to msg & "<span style=\"" & valuestyle & "\">" & "/DualCore</span>"
								else
									set msg to msg & "<span style=\"" & valuestyle & "\">" & "/HTT</span>"
								end if
							end if
							if corecheck contains 1 then
								if cputypepretty contains "AMD" then
									set msg to msg & "<span style=\"" & valuestyle & "\">" & "/DualCore</span>"
								else
									set msg to msg & "<span style=\"" & valuestyle & "\">" & "/HTT</span>"
								end if
							end if
							if corecheck contains 2 then
								if cputypepretty does not contain "Intel Pentium M" then
									set msg to msg & "<span style=\"" & valuestyle & "\">" & "/DualCore</span>"
								end if
							end if
							if corecheck contains 4 then
								set msg to msg & "<span style=\"" & valuestyle & "\">" & "/QuadCore</span>"
							end if
						end if
					else
						
						if altiveccheck contains 1 then
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "AltiVec</span>"
						end if
						if corecheck contains 2 then
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "/DualCore</span>"
						end if
						if corecheck contains 4 then
							set msg to msg & "<span style=\"" & valuestyle & "\">" & "/QuadCore</span>"
						end if
					end if
					set msg to msg & "</span>]</span> "
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("L2 Cache") then
					set current_script_location to "l2 cache output"
					set l2cache to l2cache / 1024
					set l2Measure to "KB "
					if l2cache &#8805; 1024 then
						set l2cache to l2cache / 1024
						set l2Measure to "MB "
					end if
					set msg to msg & "<span style=\"" & labelstyle & "\">L2 Cache:</span> <span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & cpumultiplier & (round (l2cache)) & l2Measure & "</span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("FSB Speed") then
					set current_script_location to "fsb speed output"
					set msg to msg & "<span style=\"" & labelstyle & "\">"
					if cputypepretty contains "AMD" then
						set msg to msg & "HT:"
					else
						set msg to msg & "FSB:"
					end if
					set msg to msg & "</span> <span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & cpumultiplier & fsb & "MHz </span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("RAM") then
					set current_script_location to "ram output"
					set memtotal to memtotal / 1024 / 1024
					if memtotal &#8805; 1024 then
						set memtotal to (memtotal round) / 1024
						set memmeasure to "GB"
					else
						set memmeasure to "MB"
					end if
					if usedmem &#8805; 1024 then
						set usedmem to usedmem / 1024
						set usedmem to (round (usedmem * 100)) / 100
						set usedmeasure to "GB"
					else
						set usedmem to (round (usedmem * 100)) / 100
						set usedmeasure to "MB"
					end if
					set msg to msg & "<span style=\"" & labelstyle & "\">RAM Usage:</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\"> " & usedmem & usedmeasure & "</span>/<span style=\"" & colortwo & "\">" & memtotal & memmeasure & "</span> [<span style=\"" & colortwo & "\">" & rambar & "</span>] </span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Virtual") then
					set current_script_location to "vram output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Virtual:</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\"> " & vmused & "B</span>/<span style=\"" & colortwo & "\">" & vmtotal & "B </span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Disk Usage") then
					set current_script_location to "hd output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Disk Usage:</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\"> " & allUsed & usedunit & "</span>/<span style=\"" & colortwo & "\">" & allSpace & spaceunit & " </span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				set current_script_location to "battery info output"
				if tempprefs's getKey("Battery") then
					if powerdata contains "BatteryInfo" then
						set theValue to (theCur / theMax) * 100
						set theValue to (round theValue * 10) / 10
						if theValue is 100.0 then
							set theValue to 100
						end if
						if theValue is greater than 100 then
							set theValue to 100
						end if
						set msg to msg & "<span style=\"" & labelstyle & "\">Battery:</span> <span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & theValue & "</span>%</span> "
					end if
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Display") then
					set current_script_location to "display output"
					set msg to msg & "<span style=\"" & labelstyle & "\"> Display:</span><span style=\" " & valuestyle & "\"><span style=\" " & colortwo & "\"> " & graphicspretty & " </span>[<span style=\" " & colortwo & "\">" & vrampretty
					if qecheck contains ": Supported" then
						set msg to msg & "/QE"
					end if
					if displaydata contains "Quartz 2D Extreme: Supported" then
						set msg to msg & "/Q2DE"
					end if
					if cicheck contains ": Supported" or ": Hardware Accelerated" then
						set msg to msg & "/CI"
					end if
					if cicheck contains ": Hardware Accelerated" then
						set msg to msg & "/CI"
					end if
					if displaycheck contains "1" then
						set msg to msg & "</span>]<span style=\" " & colortwo & "\"> " & respretty & " </span></span>"
					else
						set msg to msg & "</span>]<span style=\" " & colortwo & "\"> " & respretty & " </span>and<span style=\" " & colortwo & "\"> " & respretty2 & " </span></span>"
					end if
					
					
					
					if displaykextpref then
						if cpu is in {"i486", "pentium4"} then
							set msg to msg & "<span style=\"" & valuestyle & "\">[<span style=\"" & colortwo & "\">" & gfxdriver & "</span>]</span> "
						end if
					end if
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				
				if tempprefs's getKey("Audio") then
					set current_script_location to "audio output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Audio:</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\"> " & audio & " </span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				
				if tempprefs's getKey("OS Version") then
					set current_script_location to "os ver output"
					set msg to msg & "<span style=\"" & labelstyle & "\">OS:</span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\"> " & systemvernum & "</span></span>"
					
					if (count of characters in msg) is greater than rollover then
						set toolong to true
						set msg2 to msg
						set msg to ""
					else
						set toolong to false
					end if
					
					if osbuildpref then
						set msg to msg & "<span style=\"" & valuestyle & "\">(<span style=\"" & colorone & "\">" & buildnum & "</span>) </span>"
					end if
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Kernel Version") then
					set current_script_location to "kernel ver output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Kernel Build:</span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\"> " & kernelnum & " </span>"
					
					if (count of characters in msg) is greater than rollover then
						set toolong to true
						set msg2 to msg
						set msg to ""
					else
						set toolong to false
					end if
					
					set msg to msg & "(<span style=\"" & colorone & "\">10." & osnum
					if kernelbuildnum does not contain "0" then
						set msg to msg & "." & kernelbuildnum
					end if
					set msg to msg & "</span>) </span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Processes") then
					set current_script_location to "process output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Processes: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & procnumber & " </span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if netdisabled is false then
					if tempprefs's getKey("Network") then
						set current_script_location to "network info output"
						set msg to msg & "<span style=\"" & labelstyle & "\">Net:</span> <span style=\"" & valuestyle & "\">[<span style=\"" & colorone & "\">" & netadapter & "</span>/<span style=\"" & labelstyle & "\">In: </span><span style=\"" & colortwo & "\">" & amount_in & in_measure & "B</span>/<span style=\"" & labelstyle & "\">Out: </span><span style=\"" & colortwo & "\">" & amount_out & out_measure & "B</span>] </span>"
					end if
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Uptime") then
					set current_script_location to "uptime output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Up: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & uptime & " </span></span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Username") then
					set current_script_location to "username output"
					set msg to msg & "<span style=\"" & labelstyle & "\">User:</span> <span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & whoAmI & "</span></span> "
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if tempprefs's getKey("Colloquy version") then
					set current_script_location to "colloquy ver output"
					set msg to msg & "<span style=\"" & labelstyle & "\">Client:</span> <span style=\"" & colorone & "\"><span style=\"" & valuestyle & "\">Colloquy " & collover & " </span></span>(<span style=\"" & colorone & "\">" & collobuild & "</span>)</span>"
				end if
				
				if (count of characters in msg) is greater than rollover then
					set toolong to true
					set msg2 to msg
					set msg to ""
				else
					set toolong to false
				end if
				
				if timestamppref then
					set current_script_location to "timestamp output"
					set msg to msg & "<span style=\"" & colortwo & "\">" & dateoutput & "</span>"
				end if
				
				if msg2 is not "blah" then
					tell view to send message msg2
				end if
				if msg is not "" then
					tell view to send message msg
				end if
				set tempprefs to missing value
				set prefs to missing value
				my loadPrefs()
				return true
			end if
			
			--Automated script update code
			set current_script_location to "update function"
			if c is in {"sysupdate", "macupdate"} then
				try
					do shell script "curl -s -B http://www.personal.psu.edu/sal238/scripts/Colloquy/sysinfo.scpt.zip -o /tmp/sysinfo.scpt.zip"
					do shell script "zip -r -j ~/Library/Application\\ Support/Colloquy/Plugins/backup.zip ~/Library/Application\\ Support/Colloquy/Plugins/sysinfo.scpt"
					try
						do shell script "zip -r -j ~/Library/Application\\ Support/Colloquy/Plugins/prefbackup.zip ~/Library/Preferences/Colloquy\\ Prefs\\ -\\ Sysinfo\\ KK"
					end try
					do shell script "unzip -o -qq /tmp/sysinfo.scpt.zip -d ~/Library/Application\\ Support/Colloquy/Plugins/"
					do shell script "rm /tmp/sysinfo.scpt.zip"
					try
						do shell script "rm ~/Library/Preferences/Colloquy\\ Prefs\\ -\\ Sysinfo\\ KK"
					end try
					tell view to add event message "Update Successful! To load new version type /reload plugins" with name "sysinfo"
					my loadPrefs()
				on error err
					do shell script "rm /tmp/sysinfo.scpt.zip"
					tell view to add event message "Update Failed:" & err with name "sysinfo"
				end try
			end if
			
			--Code to check what is currently playing in Xbox Media Center
			set current_script_location to "xbmc code"
			if c is in {"xbmc"} then
				
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				set xboxip to prefs's getKey("Xbox IP")
				if arguments is "" then
					set AppleScript's text item delimiters to ":"
					try
						set xbmctemp to do shell script "curl --connect-timeout 2 -f http://" & xboxip & "/xbmcCmds/xbmcHttp?command=getcurrentlyplaying"
						set AppleScript's text item delimiters to "<li>"
						set xbmcplaying to text item 5 of xbmctemp
						set xbmctime to text item 8 of xbmctemp
						set xbmcdur to text item 9 of xbmctemp
						set AppleScript's text item delimiters to ":"
						set xbmcplaying to text item 2 of xbmcplaying
						set AppleScript's text item delimiters to ":"
						set xbmctime1 to text item 2 of xbmctime
						set xbmctime2 to text item 3 of xbmctime
						set xbmctime3 to characters 1 through 2 of text item 4 of xbmctime
						set xbmcdur1 to text item 2 of xbmcdur
						set xbmcdur2 to text item 3 of xbmcdur
						set xbmcdur3 to text item 4 of xbmcdur
						set msg to "is watching <span style=\"" & valuestyle & "\">"
						set AppleScript's text item delimiters to ""
						set msg to msg & "<span style=\"" & colorone & "\">" & xbmcplaying & "</span> Position: <span style=\"" & colortwo & "\">"
						if xbmcdur1 is not "00" then
							set msg to msg & xbmctime1 & ":"
						end if
						set msg to msg & xbmctime2 & ":" & xbmctime3 & "</span>/<span style=\"" & colortwo & "\">"
						if xbmcdur1 is not "00" then
							set msg to msg & xbmcdur1 & ":"
						end if
						set msg to msg & xbmcdur2 & ":" & xbmcdur3
						set msg to msg & "</span> via <span style=\"font-weight:bold; color:green\">Xbox Media Center</span>"
					on error err
						set msg to "isn't running Xbox Media Center currently."
						--tell view to add event message err
					end try
					tell view to send message msg with action tense
				else
					set xbmccommand to first word of arguments
					set xbmcexec to do shell script "curl --connect-timeout 2 -f http://" & xboxip & "/xbmcCmds/xbmcHttp?command=" & xbmccommand
				end if
			end if
			
			--Display current weather			
			set current_script_location to "weather code"
			if c is in {"weather"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				try
					set targetzip to first word of arguments as string
					set tempurl to "http://xml.weather.yahoo.com/forecastrss?p=" & targetzip
					set cmd to do shell script "curl " & tempurl & " -o /tmp/macweather.xml"
					set weathertmp to "/tmp/macweather.xml"
					tell application "System Events"
						set the_xml to (contents of XML file weathertmp)
						set city to the value of XML attribute "city" of XML element "yweather:location" of XML element "channel" of XML element "rss" of the_xml
						set region to the value of XML attribute "region" of XML element "yweather:location" of XML element "channel" of XML element "rss" of the_xml
						set country to the value of XML attribute "country" of XML element "yweather:location" of XML element "channel" of XML element "rss" of the_xml
						set temporig to the value of XML attribute "temp" of XML element "yweather:condition" of XML element "item" of XML element "channel" of XML element "rss" of the_xml
						set realorig to the value of XML attribute "chill" of XML element "yweather:wind" of XML element "channel" of XML element "rss" of the_xml
						set windmph to the value of XML attribute "speed" of XML element "yweather:wind" of XML element "channel" of XML element "rss" of the_xml
						set winddir to the value of XML attribute "direction" of XML element "yweather:wind" of XML element "channel" of XML element "rss" of the_xml
						set wtext to the value of XML attribute "text" of XML element "yweather:condition" of XML element "item" of XML element "channel" of XML element "rss" of the_xml
						set tempunit to the value of XML attribute "temperature" of XML element "yweather:units" of XML element "channel" of XML element "rss" of the_xml
						if tempunit contains "C" then
							set tempc to temporig
							set realc to realorig
							set tempf to (tempc + 32) * 9 / 5 round
							set realf to (realc + 32) * 9 / 5 round
						else
							set tempf to temporig
							set realf to realorig
							set tempc to (tempf - 32) * 5 / 9 round
							set realc to (realf - 32) * 5 / 9 round
						end if
						set windkm to windmph * 1.609
						set windkm to (round windkm * 10) / 10
						if winddir is greater than or equal to 0 and winddir is less than 24 then
							set direction to "North"
						else if winddir is greater than 23 and winddir is less than 69 then
							set direction to "North East"
						else if winddir is greater than 68 and winddir is less than 114 then
							set direction to "East"
						else if winddir is greater than 113 and winddir is less than 159 then
							set direction to "South East"
						else if winddir is greater than 158 and winddir is less than 204 then
							set direction to "South"
						else if winddir is greater than 203 and winddir is less than 249 then
							set direction to "South West"
						else if winddir is greater than 248 and winddir is less than 294 then
							set direction to "West"
						else if winddir is greater than 293 and winddir is less than 339 then
							set direction to "North West"
						else
							set direction to "North"
						end if
					end tell
					set msg to "<span style=\"" & valuestyle & "\">Current weather for <span style=\"" & colorone & "\"><span style=\"" & labelstyle & "\">" & city & ", " & region & " (" & country & ")</span></span>: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & wtext & " </span></span><span style=\"" & labelstyle & "\">Temp: </span><span style=\"" & colortwo & "\"><span style=\"" & valuestyle & "\">" & tempf & " F/" & tempc & " C</span></span><span style=\"" & labelstyle & "\"> Feels Like: </span><span style=\"" & colortwo & "\"><span style=\"" & valuestyle & "\">" & realf & " F/" & realc & " C</span></span><span style=\"" & labelstyle & "\"> Wind: </span><span style=\"" & colortwo & "\"><span style=\"" & valuestyle & "\">" & windmph & " mph/" & windkm & " km " & direction & "</span></span>"
					tell view to send message msg
				on error err
					tell view to add event message "Please follow weather with a valid zipcode" with name "sysinfo"
				end try
				return true
			end if
			
			set current_script_location to "international weather code"
			if c is in {"weatherca"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				try
					if (count of words in arguments) is 1 then
						set blah to first word of arguments
					else if (count of words in arguments) is 2 then
						set blah to first word of arguments & "%20" & second word of arguments
					else if (count of words in arguments) is 3 then
						set blah to first word of arguments & "%20" & second word of arguments & "%20" & third word of arguments
					else
						set blah to first word of arguments
					end if
					set tempurl to "http://xoap.weather.com/search/search?where=" & blah
					set cmd to do shell script "curl " & tempurl & " -o /tmp/macweather.xml"
					set weathertmp to "/tmp/macweather.xml"
					tell application "System Events"
						set the_xml to (contents of XML file weathertmp)
						set postal to the value of XML attribute "id" of XML element "loc" of XML element "search" of the_xml
					end tell
					set tempurl to "http://xml.weather.yahoo.com/forecastrss?p=" & postal
					set cmd to do shell script "curl " & tempurl & " -o /tmp/macweather.xml"
					set weathertmp to "/tmp/macweather.xml"
					tell application "System Events"
						set the_xml to (contents of XML file weathertmp)
						set city to the value of XML attribute "city" of XML element "yweather:location" of XML element "channel" of XML element "rss" of the_xml
						set region to the value of XML attribute "region" of XML element "yweather:location" of XML element "channel" of XML element "rss" of the_xml
						set country to the value of XML attribute "country" of XML element "yweather:location" of XML element "channel" of XML element "rss" of the_xml
						set temporig to the value of XML attribute "temp" of XML element "yweather:condition" of XML element "item" of XML element "channel" of XML element "rss" of the_xml
						set realorig to the value of XML attribute "chill" of XML element "yweather:wind" of XML element "channel" of XML element "rss" of the_xml
						set windmph to the value of XML attribute "speed" of XML element "yweather:wind" of XML element "channel" of XML element "rss" of the_xml
						
						set wtext to the value of XML attribute "text" of XML element "yweather:condition" of XML element "item" of XML element "channel" of XML element "rss" of the_xml
						set tempunit to the value of XML attribute "temperature" of XML element "yweather:units" of XML element "channel" of XML element "rss" of the_xml
						if tempunit contains "C" then
							set tempc to temporig
							set realc to realorig
							set tempf to (tempc + 32) * 9 / 5 round
							set realf to (realc + 32) * 9 / 5 round
						else
							set tempf to temporig
							set realf to realorig
							set tempc to (tempf - 32) * 5 / 9 round
							set realc to (realf - 32) * 5 / 9 round
						end if
						set windkm to windmph * 1.609
						set windkm to (round windkm * 10) / 10
					end tell
					set msg to "<span style=\"" & valuestyle & "\">Current weather for <span style=\"" & colorone & "\"><span style=\"" & labelstyle & "\">" & city
					if region is not "" then
						set msg to msg & ", " & region
					end if
					set msg to msg & " (" & country & ")</span></span>: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & wtext & " </span></span><span style=\"" & labelstyle & "\">Temp: </span><span style=\"" & colortwo & "\"><span style=\"" & valuestyle & "\">" & tempf & " F/" & tempc & " C</span></span><span style=\"" & labelstyle & "\"> Feels Like: </span><span style=\"" & colortwo & "\"><span style=\"" & valuestyle & "\">" & realf & " F/" & realc & " C</span></span><span style=\"" & labelstyle & "\"> Wind: </span><span style=\"" & colortwo & "\"><span style=\"" & valuestyle & "\">" & windmph & " mph/" & windkm & " km " & "</span></span>"
					tell view to send message msg
				on error err
					tell view to add event message "Location not found, or some other problem" with name "sysinfo"
					--tell view to add event message err
				end try
				return true
			end if
			
			--Code to display current Azureus transfer data
			set current_script_location to "azureus code"
			if c is in {"az"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				try
					set aztemp to prefs's getKey("Az Stat Location")
					tell application "System Events"
						set dlspeed to value of XML element "text" of XML element "download_speed" of XML element "global" of XML element "stats" of XML file aztemp
						set ulspeed to value of XML element "text" of XML element "upload_speed" of XML element "global" of XML element "stats" of XML file aztemp
						
					end tell
					set msg to "<span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">Azureus Data </span></span><span style=\"" & labelstyle & "\">Down: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & dlspeed & "</span></span><span style=\"" & labelstyle & "\"> Up: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & ulspeed & "</span></span>"
					tell view to send message msg
				on error
					tell view to add event message "Azureus is either not configured, or not running" with name "sysinfo"
					set check to 0
				end try
			end if
			
			if c is in {"azureus", "azfull"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				try
					set aztemp to prefs's getKey("Az Stat Location")
					tell application "System Events"
						set dlspeed to value of XML element "text" of XML element "download_speed" of XML element "global" of XML element "stats" of XML file aztemp
						set ulspeed to value of XML element "text" of XML element "upload_speed" of XML element "global" of XML element "stats" of XML file aztemp
						
					end tell
					set msg to "<span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">Azureus Data </span></span><span style=\"" & labelstyle & "\">Down: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & dlspeed & "</span></span><span style=\"" & labelstyle & "\"> Up: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & ulspeed & "</span></span>"
					tell view to send message msg
					
				end try
				
				set x to 1
				set AppleScript's text item delimiters to " "
				try
					set check to do shell script "cat " & aztemp & " | grep -a '<DOWNLOAD>' -c"
				on error
					tell view to add event message "Azureus is either not configured, or not running" with name "sysinfo"
					set check to 0
				end try
				repeat check times
					try
						tell application "System Events"
							set the_xml to (contents of XML file aztemp)
							set azdown to XML element x of XML element "downloads" of XML element "stats" of the_xml
							set dlstatus to value of XML element "download_status" of azdown
							set tname to value of XML element "name" of XML element "torrent" of azdown
							set tspeed to value of XML element "text" of XML element "download_speed" of azdown
							set tspeedraw to value of XML element "raw" of XML element "download_speed" of azdown
							set tuspeed to value of XML element "text" of XML element "upload_speed" of azdown
							set seeders to value of XML element "total_seeds" of azdown
							set leechers to value of XML element "total_leechers" of azdown
							set downloaded to value of XML element "raw" of XML element "downloaded" of azdown
							set fsizeraw to value of XML element "raw" of XML element "size" of XML element "torrent" of azdown
							set fsize to value of XML element "text" of XML element "size" of XML element "torrent" of azdown
							set discarded to value of XML element "raw" of XML element "discarded" of azdown
							if downloaded is greater than 0 then
								set eta to value of XML element "eta" of azdown
							else
								set eta to "Unknown"
							end if
							set x to x + 1
						end tell
					on error err
						tell view to add event message "Error: " & err & " @ azureus code" with name "sysinfo"
						set check to 0
					end try
					
					set azpercent to (downloaded - discarded) / fsizeraw * 100
					set azpercent to (round azpercent * 100) / 100
					if azpercent is greater than 100 then
						set azpercent to 100
					end if
					set downloadmsg to "<span style=\"" & labelstyle & "\">Name: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & tname & "</span></span><span style=\"" & labelstyle & "\"> (</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & azpercent & "% </span> of <span style=\"" & colortwo & "\">" & fsize & "</span></span><span style=\"" & labelstyle & "\">) </span><span style=\"" & labelstyle & "\"> Seeds: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & seeders & "</span></span><span style=\"" & labelstyle & "\"> Leechers: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & leechers & "</span></span><span style=\"" & labelstyle & "\"> ETA: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & eta & "</span>" & " @ <span style=\"" & colortwo & "\">" & tspeed & "</span> down and <span style=\"" & colortwo & "\">" & tuspeed & "</span> up</span>"
					tell view to send message downloadmsg
				end repeat
			end if
			
			set current_script_location to "quicktime code"
			if c is in {"quicktime", "qt"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				
				tell application "System Events"
					set quicktimeRunning to ((application processes whose name is equal to "QuickTime Player") count) is greater than 0
				end tell
				if arguments is "" then
					if quicktimeRunning then
						tell application "QuickTime Player"
							set qtstream to live stream of document 1
							set qtplaying to playing of document 1
							set qtname to name of document 1
							set qtduration to duration of document 1
							set qtcurtime to current time of document 1
							set qttimescale to time scale of document 1
							copy the natural dimensions of document 1 to {qtmovie_height, qtmovie_width}
						end tell
						
						set qtcur to round (qtcurtime / qttimescale) rounding down
						set qttot to round (qtduration / qttimescale) rounding down
						if qttot is less than 3600 then
							set qtplaces to "2"
						else
							set qtplaces to "3"
						end if
						
						if qtplaying is true then
							if qtmovie_height is 0 and qtmovie_width is 0 then
								set whatdoing to "is listening to"
							else
								set whatdoing to "is watching"
							end if
						else if qtstream is true then
							set whatdoing to "is streaming"
						end if
						
						if qtplaying is true or qtstream is true then
							set msg to "<span style=\"" & valuestyle & "\">" & whatdoing & " <span style=\"" & colorone & "\">" & qtname & "</span> Position: <span style=\"" & colortwo & "\">" & convertTime(qtcur, qtplaces) & "</span>/<span style=\"" & colortwo & "\">" & convertTime(qttot, qtplaces) & "</span> "
							if whatdoing is "is watching" then
								set msg to msg & "Resolution: <span style=\"" & colortwo & "\">" & qtmovie_height & "x" & qtmovie_width & "</span>"
							end if
							set msg to msg & "</span></span> via <span style=\"font-weight:bold; color:blue\">QuickTime Player</span>"
						else
							set msg to "<span style=\"" & valuestyle & "\">has QuickTime Player paused.</span>"
						end if
					else
						set msg to "<span style=\"" & valuestyle & "\">isn't running QuickTime Player currently.</span>"
					end if
					tell view to send message msg with action tense
				else if first word of arguments is "open" then
					ignoring application responses
						tell application "QuickTime Player" to activate
					end ignoring
				else if first word of arguments is "quit" and quicktimeRunning then
					ignoring application responses
						tell application "QuickTime Player" to quit
					end ignoring
				else if first word of arguments is "play" then
					ignoring application responses
						tell application "QuickTime Player" to play document 1
					end ignoring
				else if first word of arguments is "pause" and quicktimeRunning then
					ignoring application responses
						tell application "QuickTime Player" to pause document 1
					end ignoring
				else if first word of arguments is "stop" and quicktimeRunning then
					ignoring application responses
						tell application "QuickTime Player" to stop document 1
					end ignoring
					
					
				end if
			end if
			
			set current_script_location to "vlc code"
			if c is in {"videolan", "vlc"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				
				tell application "System Events"
					set vlcRunning to ((application processes whose name is equal to "VLC") count) is greater than 0
				end tell
				if arguments is "" then
					set vlcport to 8084
					if vlcRunning then
						set vlctemp to do shell script "curl --connect-timeout 2 -f http://127.0.0.1:" & vlcport & "/old/ | grep 'State:'"
						set AppleScript's text item delimiters to ": "
						set vlctemp to text item 2 of vlctemp
						set AppleScript's text item delimiters to "<"
						set vlcstate to text item 1 of vlctemp
						if vlcstate contains "playing" then
							set vlctemp to do shell script "curl --connect-timeout 2 -f http://127.0.0.1:" & vlcport & "/old/ | grep -A 5 '<strong>'"
							set AppleScript's text item delimiters to ">"
							set vlctemp to text item 3 of vlctemp
							set AppleScript's text item delimiters to "("
							set vlcplaying to text item 1 of vlctemp
							set vlctemp to do shell script "curl --connect-timeout 2 -f http://127.0.0.1:" & vlcport & "/old/ | grep 'Length:'"
							set AppleScript's text item delimiters to ">"
							set vlctemp to text item 2 of vlctemp
							set AppleScript's text item delimiters to " "
							set vlclength to text item 1 of vlctemp
							set vlctemp to do shell script "curl --connect-timeout 2 -f http://127.0.0.1:" & vlcport & "/old/ | grep 'Time:'"
							set AppleScript's text item delimiters to ">"
							set vlctemp to text item 2 of vlctemp
							set AppleScript's text item delimiters to " "
							set vlctime to text item 1 of vlctemp
							
							if vlclength is less than 3600 and vlclength is greater than 0 then
								set vlcplaces to "2"
							else
								set vlcplaces to "3"
							end if
							
							set msg to "<span style=\"" & valuestyle & "\">is watching <span style=\"" & colorone & "\">" & vlcplaying & "</span> Position: <span style=\"" & colortwo & "\">" & convertTime(vlctime, vlcplaces) & "</span>/<span style=\"" & colortwo & "\">" & convertTime(vlclength, vlcplaces) & "</span></span>"
							set msg to msg & "</span> via <span style=\"font-weight:bold; color:orange\">VideoLAN</span>"
						else if vlcstate contains "paused" then
							set msg to "<span style=\"" & valuestyle & "\">has VideoLAN paused.</span>"
						else
							set msg to "<span style=\"" & valuestyle & "\">has VideoLAN stopped.</span>"
						end if
					else
						set msg to "<span style=\"" & valuestyle & "\">isn't running VideoLAN currently.</span>"
					end if
					tell view to send message msg with action tense
					
				end if
			end if
			
			
			set current_script_location to "itunes code"
			if c is in {"mactunes", "tunes"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				tell application "System Events"
					set itunesRunning to ((application processes whose name is equal to "iTunes") count) is greater than 0
				end tell
				if arguments is "" then
					if itunesRunning then
						set italbum to ""
						set itartist to ""
						set itvideocheck to "music"
						set byline to " by "
						set fromline to " from "
						tell application "iTunes"
							
							if class of current track is URL track then
								set ittitle to current stream title
								set italbum to name of current track
								set itstream to true
							else
								set italbum to album of current track
								set itartist to artist of current track
								set ittitle to name of current track
								set itstream to false
							end if
							set itbitrate to the bit rate of current track
							set itdur to duration of current track
							set itrating to rating of current track
							set itpos to player position
							set itvideocheck to kind of current track as string
							if player state is playing then
								set itplaying to true
							else
								set itplaying to false
							end if
						end tell
						
						if itdur is not missing value then
							if itdur is less than 3600 then
								set itplaces to "2"
							else
								set itplaces to "3"
							end if
						end if
						
						set ratingbar to "<span style=\"color:grey\">"
						set stars to (itrating div 20) as integer
						set fullstars to stars
						set emptystars to 5 - stars
						repeat fullstars times
							set ratingbar to ratingbar & "&#x272E;"
						end repeat
						repeat emptystars times
							set ratingbar to ratingbar & "&#x2729;"
						end repeat
						set ratingbar to ratingbar & "</span>"
						
						if itvideocheck contains "movie" then
							set whatdoing to "watching"
						else if itvideocheck contains "video" then
							set whatdoing to "watching"
						else if itstream then
							set whatdoing to "streaming"
						else
							set whatdoing to "listening to"
						end if
						
						if itartist is "" then
							set byline to ""
						end if
						if italbum is "" then
							set fromline to ""
						end if
						
						
						if itplaying is true then
							set msg to "<span style=\"" & valuestyle & "\">is " & whatdoing & " <span style=\"" & colortwo & "\">" & ittitle & "</span>" & byline & "<span style=\"" & colorone & "\">" & itartist & "</span>"
							if itartist is not equal to italbum then
								set msg to msg & fromline & "<span style=\"" & colortwo & "\">" & italbum & "</span>"
							end if
							if itdur is not missing value then
								set msg to msg & " Position: <span style=\"" & colortwo & "\">" & convertTime(itpos, itplaces) & "</span>/<span style=\"" & colortwo & "\">" & convertTime(itdur, itplaces) & "</span>"
							end if
							set msg to msg & " Bitrate: <span style=\"" & colortwo & "\">" & itbitrate & "kbps</span> Rating: [<span style=\"" & colortwo & "\">" & ratingbar & "</span>]</span>"
						else
							set msg to "<span style=\"" & valuestyle & "\">has iTunes paused.</span>"
						end if
					else
						set msg to "<span style=\"" & valuestyle & "\">isn't running iTunes currently.</span>"
					end if
					tell view to send message msg with action tense
				else if first word of arguments is "what" and itunesRunning then
					tell application "iTunes"
						set itvideocheck to kind of current track as string
					end tell
					tell view to send message itvideocheck
				else if first word of arguments is "open" then
					ignoring application responses
						tell application "iTunes" to activate
					end ignoring
				else if first word of arguments is "quit" and itunesRunning then
					ignoring application responses
						tell application "iTunes" to quit
					end ignoring
				else if first word of arguments is "play" then
					ignoring application responses
						tell application "iTunes" to play
					end ignoring
				else if first word of arguments is "pause" and itunesRunning then
					ignoring application responses
						tell application "iTunes" to pause
					end ignoring
				else if first word of arguments is "stop" and itunesRunning then
					ignoring application responses
						tell application "iTunes" to stop
					end ignoring
				else if first word of arguments is "next" and itunesRunning then
					ignoring application responses
						tell application "iTunes" to next track
					end ignoring
				else if first word of arguments is "previous" and itunesRunning then
					ignoring application responses
						tell application "iTunes" to previous track
					end ignoring
				end if
			end if
			
			set current_script_location to "exec code"
			if c is in {"exec"} then
				set outputtmp to do shell script arguments
				tell view to add event message outputtmp
			end if
			
			set current_script_location to "execo code"
			if c is in {"execo"} then
				set outputtmp to do shell script arguments
				tell view to send message outputtmp
			end if
			
			set current_script_location to "execs code"
			if c is in {"execs"} then
				set outputtmp to do shell script arguments with administrator privileges
				tell view to add event message outputtmp
			end if
			
			set current_script_location to "execos code"
			if c is in {"execos"} then
				set outputtmp to do shell script arguments with administrator privileges
				tell view to send message outputtmp
			end if
			
			set current_script_location to "Geekbench code"
			if c is in {"geekbench", "gb"} then
				my loadPrefs()
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set labelstyle to prefs's getKey("Label Style")
				set valuestyle to prefs's getKey("Value Style")
				set gbid to prefs's getKey("GeekBench ID")
				set gbid2 to prefs's getKey("GeekBench ID 2")
				set gbrid to prefs's getKey("GeekBench-Rosetta ID")
				set msg to "<span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">GeekBench</span></span> "
				if gbid is not "00000" then
					ignoring application responses
						do shell script "curl --output /tmp/geekbench.txt http://www.geekpatrol.ca/browse/2006/?view" & (ASCII character of 92) & "&id=" & gbid
					end ignoring
					set gbtemp to do shell script "cat /tmp/geekbench.txt | grep 'Overall Score:'"
					set AppleScript's text item delimiters to ":"
					set gbtemp to text item 2 of gbtemp
					set AppleScript's text item delimiters to "<"
					set gbscore to text item 1 of gbtemp
					set gbtemp to do shell script "cat /tmp/geekbench.txt | grep -m 1 'Mac OS X'"
					set AppleScript's text item delimiters to "("
					set gbtemp to text item 2 of gbtemp
					set AppleScript's text item delimiters to ")"
					set gbbits to text item 1 of gbtemp
					set msg to msg & "<span style=\"" & labelstyle & "\">Normal (" & gbbits & "): </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & gbscore & "</span></span>"
				else
					set gbscore to "none"
				end if
				if gbid2 is not "00000" then
					ignoring application responses
						do shell script "curl --output /tmp/geekbench2.txt http://www.geekpatrol.ca/browse/2006/?view" & (ASCII character of 92) & "&id=" & gbid2
					end ignoring
					set gbtemp to do shell script "cat /tmp/geekbench2.txt | grep 'Overall Score:'"
					set AppleScript's text item delimiters to ":"
					set gbtemp to text item 2 of gbtemp
					set AppleScript's text item delimiters to "<"
					set gbscore to text item 1 of gbtemp
					set gbtemp to do shell script "cat /tmp/geekbench2.txt | grep -m 1 'Mac OS X'"
					set AppleScript's text item delimiters to "("
					set gbtemp to text item 2 of gbtemp
					set AppleScript's text item delimiters to ")"
					set gbbits to text item 1 of gbtemp
					set msg to msg & "<span style=\"" & labelstyle & "\">Normal (" & gbbits & "): </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & gbscore & "</span></span>"
				else
					set gbscore to "none"
				end if
				if gbrid is not "00000" then
					ignoring application responses
						do shell script "curl --output /tmp/geekbench-rosetta.txt http://www.geekpatrol.ca/browse/2006/?view" & (ASCII character of 92) & "&id=" & gbrid
					end ignoring
					set gbtemp to do shell script "cat /tmp/geekbench-rosetta.txt | grep 'Overall Score:'"
					set AppleScript's text item delimiters to ":"
					set gbtemp to text item 2 of gbtemp
					set AppleScript's text item delimiters to "<"
					set gbrscore to text item 1 of gbtemp
					set gbtemp to do shell script "cat /tmp/geekbench.txt | grep -m 1 'Mac OS X'"
					set AppleScript's text item delimiters to "("
					set gbtemp to text item 2 of gbtemp
					set AppleScript's text item delimiters to ")"
					set gbbits to text item 1 of gbtemp
					set msg to msg & " <span style=\"" & labelstyle & "\">Rosetta (" & gbbits & "):</span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\"> " & gbrscore & "</span></span>"
				end if
				tell view to send message msg
			end if
			
			set current_script_location to "del pref code"
			if c is in {"delprefs"} then
				do shell script "rm ~/Library/Preferences/Colloquy\\ Prefs\\ -\\ Sysinfo\\ KK"
				reload plugins
			end if
			
			set current_script_location to "halo 2 stat code"
			if c is in {"halo2"} then
				my loadPrefs()
				set backuptag to prefs's getKey("Xbox Live GamerTag")
				set labelstyle to prefs's getKey("Label Style") --& ";color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set valuestyle to prefs's getKey("Value Style") --& ";color:" & my rgbStringOf(prefs's getKey("Color 2"))	
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				if arguments is not "" then
					if (count of words in arguments) is 1 then
						set gamertag to first word of arguments
					else if (count of words in arguments) is 2 then
						set gamertag to first word of arguments & "%20" & second word of arguments
					else if (count of words in arguments) is 3 then
						set gamertag to first word of arguments & "%20" & second word of arguments & "%20" & third word of arguments
					end if
				else if backuptag is not missing value then
					if (count of words in backuptag) is 1 then
						set gamertag to first word of backuptag
					else if (count of words in backuptag) is 2 then
						set gamertag to first word of backuptag & "%20" & second word of backuptag
					else if (count of words in backuptag) is 3 then
						set gamertag to first word of backuptag & "%20" & second word of backuptag & "%20" & third word of backuptag
					end if
				end if
				try
					do shell script "curl http://scripts.blakbox.net/xml/halo2.php?tag=" & gamertag & " -o /tmp/halo2.xml"
					do shell script "curl http://www.bungie.net/stats/halo2rss.ashx?g=" & gamertag & " -o /tmp/halo2breakdown.xml"
				on error
					tell view to add event message "Please enter a valid Xbox Live Gamertag"
				end try
				tell application "System Events"
					set the_xml to (contents of XML file "/tmp/halo2.xml")
					set tag to value of XML element "gamertag" of XML element "main" of XML element "halo2" of the_xml
					set kdr to value of XML element "kdratio" of XML element "main" of XML element "halo2" of the_xml
					set games to value of XML element "games" of XML element "total" of XML element "halo2" of the_xml
					set kills to value of XML element "kills" of XML element "total" of XML element "halo2" of the_xml
					set deaths to value of XML element "deaths" of XML element "total" of XML element "halo2" of the_xml
					set assists to value of XML element "assists" of XML element "total" of XML element "halo2" of the_xml
					--set the_xml2 to (contents of XML file "/tmp/halo2breakdown.xml")
					--set lastdesc to value of XML element 1 of the_xml2
					--set lasttime to value of XML element 2 of the_xml2
					
					
					
				end tell
				
				set msg to "<span style=\"font-weight:bold;color:blue\">Halo 2 Stats </span><span style=\"" & labelstyle & "\">GamerTag: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & tag & " </span></span><span style=\"" & labelstyle & "\">Games: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & games & " </span></span><span style=\"" & labelstyle & "\">Kills: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & kills & " </span></span><span style=\"" & labelstyle & "\">Deaths: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & deaths & " </span></span><span style=\"" & labelstyle & "\">Kill to Death Ratio: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & kdr & "</span></span>"
				tell view to send message msg
				--tell view to add event message msg
			end if
			
			set current_script_location to "xbox live stat code"
			if c is in {"live", "xbl", "360"} then
				my loadPrefs()
				set backuptag to prefs's getKey("Xbox Live GamerTag")
				set labelstyle to prefs's getKey("Label Style") --& ";color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set valuestyle to prefs's getKey("Value Style") --& ";color:" & my rgbStringOf(prefs's getKey("Color 2"))
				set colorone to "color:" & my rgbStringOf(prefs's getKey("Color 1"))
				set colortwo to "color:" & my rgbStringOf(prefs's getKey("Color 2"))
				if arguments is not "" then
					if (count of words in arguments) is 1 then
						set gamertag to first word of arguments
					else if (count of words in arguments) is 2 then
						set gamertag to first word of arguments & "%20" & second word of arguments
					else if (count of words in arguments) is 3 then
						set gamertag to first word of arguments & "%20" & second word of arguments & "%20" & third word of arguments
					end if
				else if backuptag is not missing value then
					if (count of words in backuptag) is 1 then
						set gamertag to first word of backuptag
					else if (count of words in backuptag) is 2 then
						set gamertag to first word of backuptag & "%20" & second word of backuptag
					else if (count of words in backuptag) is 3 then
						set gamertag to first word of backuptag & "%20" & second word of backuptag & "%20" & third word of backuptag
					end if
				end if
				
				try
					do shell script "curl http://scripts.blakbox.net/xml/gamercard.php?tag=" & gamertag & " -o /tmp/xbl.xml"
				on error
					tell view to add event message "Please enter a valid Xbox Live Gamertag"
				end try
				tell application "System Events"
					set the_xml to (contents of XML file "/tmp/xbl.xml")
					set tag to value of XML element "gamertag" of XML element "gamercard" of the_xml
					set rep to value of XML element "rep" of XML element "gamercard" of the_xml
					set score to value of XML element "gamerscore" of XML element "gamercard" of the_xml
					set |zone| to value of XML element "zone" of XML element "gamercard" of the_xml
					set recentgame to value of XML element "title" of XML element "game1" of XML element "acheivements" of XML element "gamercard" of the_xml
				end tell
				
				if c is in {"live", "xbl"} then
					set msg to "<span style=\"font-weight:bold;color:green\">Xbox Live Stats </span><span style=\"" & labelstyle & "\">GamerTag: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & tag & " </span></span><span style=\"" & labelstyle & "\">Reputation: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & rep & " </span></span><span style=\"" & labelstyle & "\">GamerScore: </span><span style=\"" & valuestyle & "\"><span style=\"" & colorone & "\">" & score & " </span></span><span style=\"" & labelstyle & "\">Zone: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & zone & " </span></span><span style=\"" & labelstyle & "\">Last Game Played: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & recentgame & "</span></span>"
					tell view to send message msg
				else if c is in {"360"} then
					set msg to "<span style=\"" & valuestyle & "\"> is playing <span style=\"" & colortwo & "\">" & recentgame & "</span> via <span style=\"font-weight:bold;color:green\">Xbox 360</span> <span style=\"" & labelstyle & "\">GamerTag: </span><span style=\"" & valuestyle & "\"><span style=\"" & colortwo & "\">" & tag & " </span></span></span>"
					tell view to send message msg with action tense
				end if
				
			end if
			
		on error err
			tell view to add event message "Error: " & err & " @ " & current_script_location with name "sysinfo"
			tell view to add event message "Try deleting script settings using /delprefs"
			tell view to add event message "If problem persists, come to #scripts on irc.macspeak.net and tell me (KanadaKid)"
		end try
		return false
	end process user command
	
end using terms from

script prefsTemplate
	--The last two wont do anything on desktop machines
	property theKeys : {¬
		{label:"Name", value:false}, ¬
		{label:"CPU Type", value:true}, ¬
		{label:"--CPU Frequency", value:true}, ¬
		{label:"--CPU Stats", value:true}, ¬
		{label:"--L2 Cache", value:true}, ¬
		{label:"--FSB Speed", value:true}, ¬
		{label:"RAM", value:true}, ¬
		{label:"Virtual", value:true}, ¬
		{label:"Disk Usage", value:true}, ¬
		{label:"Battery", value:true}, ¬
		{label:"Display", value:true}, ¬
		{label:"Audio", value:true}, ¬
		{label:"OS Version", value:true}, ¬
		{label:"--Build Number", value:true}, ¬
		{label:"Kernel Version", value:false}, ¬
		{label:"Uptime", value:true}, ¬
		{label:"Processes", value:true}, ¬
		{label:"Username", value:false}, ¬
		{label:"Network", value:false}, ¬
		{label:"Colloquy version", value:false}, ¬
		{label:"Timestamp", value:true}, ¬
		{label:"Label Style", value:"font-weight:bold"}, ¬
		{label:"Value Style", value:""}, ¬
		{label:"Color 1", value:{0, 0, 65270}}, ¬
		{label:"Color 2", value:{0, 40000, 0}}, ¬
		{label:"Stealth Mode", value:false}, ¬
		{label:"Replacement Name", value:"Hackint0sh"}, ¬
		{label:"Display Info Override", value:false}, ¬
		{label:"--Override Value", value:"Graphics Card"}, ¬
		{label:"Display Kext Info", value:false}, ¬
		{label:"Xbox IP", value:""}, ¬
		{label:"GeekBench ID", value:"00000"}, ¬
		{label:"GeekBench ID 2", value:"00000"}, ¬
		{label:"GeekBench-Rosetta ID", value:"00000"}, ¬
		{label:"Network Interface", value:"en0"}, ¬
		{label:"Xbox Live GamerTag", value:""}, ¬
		{label:"Az Stat Location", value:"/tmp/Azureus_Stats.xml"} ¬
			}
	property build : 20071214
	
	--returns true if the value was found, false if the value had to be created
	on setKey(thisLabel, newValue)
		repeat with k in theKeys
			if label of k is thisLabel then
				set value of k to newValue
				return true
			end if
		end repeat
		set theKeys to theKeys & {{label:thisLabel, value:newValue}}
		return false
	end setKey
	
	--like setKey, except it handles the interface: if it's boolean it toggles it, if it's a string it will ask for a new value, etc
	on changekey(thisLabel)
		set asd to AppleScript's text item delimiters
		set AppleScript's text item delimiters to " ("
		set thisLabel to text item 1 of thisLabel
		set oldvalue to getKey(thisLabel)
		set AppleScript's text item delimiters to asd
		if oldvalue is missing value then
			display dialog "That item (" & thisLabel & ") does not exist"
			return
		else if class of oldvalue is boolean then
			setKey(thisLabel, not oldvalue)
		else if class of oldvalue is string then
			set ans to (text returned of (display dialog "New value?" default answer oldvalue) as string)
			setKey(thisLabel, ans)
		else if class of oldvalue is integer then
			set ans to text returned of (display dialog "New value?" default answer oldvalue)
			setKey(thisLabel, ans as integer)
		else if class of oldvalue is list then
			if number of items in oldvalue is 3 then ---must be a color
				set ans to choose color default color oldvalue
				setKey(thisLabel, ans)
			else
				display dialog "Cannot edit lists of items."
			end if
		end if
	end changekey
	
	on getKey(thisLabel)
		repeat with k in theKeys
			if label of k is thisLabel then
				return value of k
			else if label of k starts with "--" and (text 3 through -1 of label of k) is thisLabel then
				return value of k
			end if
		end repeat
		return missing value
	end getKey
	
	on listKeys()
		set final to ""
		repeat with k in theKeys
			set final to final & label of k & ": " & (value of k as string) & return
		end repeat
		return final
	end listKeys
	
	on getContextMenu()
		set final to {}
		repeat with j from 1 to number of items in theKeys
			set k to item j of theKeys
			ignoring white space
				if label of k starts with "--" then
					set noPreviousUnmarkedItem to true
					repeat with i from (j - 1) to 1 by -1
						set k2 to item i of theKeys
						if label of k2 does not start with "--" then
							set noPreviousUnmarkedItem to false
							if class of value of k2 is boolean then
								set enabled to value of k2
							else
								set enabled to true
							end if
							exit repeat
						end if
					end repeat
					if noPreviousUnmarkedItem then
						set enabled to true
					end if
				else
					set enabled to true
				end if
			end ignoring
			if class of value of k is boolean then
				set final to final & {{title:label of k, checked:value of k, enabled:enabled}}
			else if class of value of k is integer or class of value of k is string then
				set final to final & {{title:label of k & " (" & value of k & ")", enabled:enabled}}
			else if class of value of k is list then
				set asd to AppleScript's text item delimiters
				set AppleScript's text item delimiters to ", "
				if number of items in value of k < 3 then
					set final to final & {{title:label of k & " (" & (every item of value of k as string) & ")", enabled:enabled}}
				else if number of items in value of k is 3 then
					set final to final & {{title:label of k, icon:value of k, enabled:enabled}}
				else
					set final to final & {{title:label of k & " (" & (items 1 through 3 of value of k as string) & ", ...)", enabled:enabled}}
				end if
				set AppleScript's text item delimiters to asd
			else
				set final to final & {{title:label of k, enabled:false, tooltip:"Unknown class of data."}}
			end if
		end repeat
		return final
	end getContextMenu
end script

on loadPrefs()
	if prefs is missing value then
		set prefsPath to (path to preferences folder from user domain as Unicode text) & "Colloquy Prefs - Sysinfo KK"
		try
			set prefs to load script alias prefsPath
			try
				build of prefs
				set prefsHasBuildProperty to true
			on error
				set prefsHasBuildProperty to false
			end try
			if prefsHasBuildProperty then
				if build of prefs < build of prefsTemplate then
					set prefs2 to prefsTemplate
					set theKeys of prefs2 to my mergeKeys(prefs, prefsTemplate)
					set prefs to prefs2
					my savePrefs()
				end if
			else --there is no build property, it must be added
				set prefs2 to prefsTemplate
				set theKeys of prefs2 to my mergeKeys(prefs, prefsTemplate)
				set prefs to prefs2
				my savePrefs()
			end if
		on error
			set prefs to prefsTemplate
		end try
	end if
end loadPrefs

on savePrefs()
	if prefs is not missing value then store script prefs in file prefsPath replacing yes
end savePrefs

--This function is used to merge keys of the old list with the values of the new one.
--Note that the first parameter is the old version of the prefs (from which the values need to be kept), and the second contains the new list (with default values to be overwritten by values gotten from oldPrefs
--returns the list to set theKeys to
on mergeKeys(oldPrefs, newDefaultPrefs)
	repeat with k in theKeys of newDefaultPrefs
		set oldvalue to oldPrefs's getKey(label of k)
		if oldvalue is not missing value then
			set value of k to oldvalue
		end if
	end repeat
	return newDefaultPrefs
end mergeKeys

on urlEncodeText(thisText, encodeGroupA, encodeGroupB)
	set the acceptableCharacters to "abcdefghijklmnopqrstuvwxyz0123456789"
	set the aCharacters to "$+!'/?;&@=#%><{}[]\"~`^\\|*"
	set the bCharacters to ".-_:"
	
	if encodeGroupA is false then ¬
		set the acceptableCharacters to the acceptableCharacters & the aCharacters
	if encodeGroupB is false then ¬
		set the acceptableCharacters to the acceptableCharacters & the bCharacters
	
	set the encodedText to ""
	repeat with thisChar in thisText
		if thisChar is in the acceptableCharacters then
			set the encodedText to (the encodedText & thisChar)
		else if thisChar is in " " then
			set the encodedText to (the encodedText & "%20")
		else
			set the encodedText to (the encodedText & urlEncodeCharacter(thisChar)) as string
		end if
	end repeat
	
	return the encodedText
end urlEncodeText

on urlEncodeCharacter(thisChar)
	set the asciiNumber to (the ASCII number thisChar)
	set the hexList to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
	
	set x to item ((asciiNumber div 16) + 1) of the hexList
	set y to item ((asciiNumber mod 16) + 1) of the hexList
	return ("%" & x & y) as string
end urlEncodeCharacter

on rgbStringOf(theColor)
	repeat with i from 1 to 3
		if item i of theColor < 256 then set item i of theColor to 256
		if item i of theColor > 65270 then set item i of theColor to 65270
	end repeat
	set rtn to "rgb(" & (round ((item 1 of theColor) / 256 - 0.5)) & "," & (round ((item 2 of theColor) / 256 - 0.5)) & "," & (round ((item 3 of theColor) / 256 - 0.5)) & ")"
	return rtn
end rgbStringOf

on convertTime(numSecs, numPlaces)
	set numSecs to round (numSecs / 1) rounding down
	set numHours to "00"
	set numMins to "00"
	if numSecs is greater than 60 then
		set numMins to round (numSecs / 60) rounding down
		if numMins is greater than 60 then
			set numHours to round (numMins / 60) rounding down
			if numHours is less than 10 then
				set numHours to "0" & numHours
			end if
			if numHours is greater than 0 then
				set numMins to numMins - (round (60 * numHours) rounding down)
			end if
		end if
		if numMins is less than 10 then
			set numMins to "0" & numMins
		end if
		if numMins is greater than 0 then
			set numSecs to numSecs - (round (60 * numMins) rounding down)
		end if
		if numHours is greater than 0 then
			set numSecs to numSecs - (round (3600 * numHours) rounding down)
		end if
	end if
	if numSecs is less than 10 then
		set numSecs to "0" & numSecs
	end if
	
	set AppleScript's text item delimiters to ""
	if numPlaces is "2" then
		set newTime to numMins & ":" & numSecs
	else
		set newTime to numHours & ":" & numMins & ":" & numSecs
	end if
	return newTime
end convertTime