All pastes #565502 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-14 00:48 UTC
rendered paste body
using terms from application "Colloquy"
	on process user command theCommand with theArguments for theView
		try
			if theCommand is "gone" then
				if theArguments is not "" then
					tell chat room panels to send message "<strong>is away: </strong>" & theArguments with action tense
					tell connections
						set the away message to theArguments
					end tell
					do shell script "defaults write com.Colloquy.awayscript 'awaym' '" & theArguments & "'"
					do shell script "defaults write com.Colloquy.awayscript 'awayt' '" & (current date) & "'"
				else
					tell chat room panels to send message "<strong>is away </strong> (no reason was provided)" with action tense
					tell connections
						set the away message to "AwayScript for Colloquy by simon360"
					end tell
					do shell script "defaults write com.Colloquy.awayscript 'awaym' 'no reason was provided'"
					do shell script "defaults write com.Colloquy.awayscript 'awayt' '" & (current date) & "'"
				end if
			end if
		on error (err)
			tell theView to add event message err
		end try
		
		if theCommand is "back" then
			set awaymess to (do shell script "defaults read com.Colloquy.awayscript 'awaym'")
			set awaytime to (do shell script "defaults read com.Colloquy.awayscript 'awaym'")
			try
				if awaytime is not "" then
					set timestampr to (current date) - (date (do shell script "defaults read com.Colloquy.awayscript 'awayt'"))
					set ghours to (timestampr div hours)
					set gminutes to (timestampr - ((ghours * 60) * 60)) div minutes
					set gseconds to (timestampr - (timestampr div minutes * 60))
					set gonetime to "Gone " & ghours & " hours, " & gminutes & " minutes, " & gseconds & " seconds."
					tell chat room panels to send message "<strong>is back</strong> (" & awaymess & "): " & gonetime with action tense
					tell connections
						set the away message to ""
					end tell
					do shell script "defaults write com.Colloquy.awayscript 'awayt' ''"
				else
					add event message "You were not set to away"
				end if
				
			on error (err)
				tell theView to add event message err
			end try
		end if
		return true
	end process user command
end using terms from