All pastes #563177 Raw Edit

Mine

public text v1 · immutable
·published 2007-06-13 01:10 UTC
rendered paste body
using terms from application "Colloquy"
	on process user command theCommand with theArguments for theView
		try
			if theCommand is "gone" or "away" then
				tell theView to send message "<strong>is away: </strong>" & theArguments to theView with action tense
				do shell script "defaults write com.Colloquy.awayscript 'awaym' '" & theArguments & "'"
				do shell script "defaults write com.Colloquy.awayscript 'awayt' '" & (current date) & "'"
			end if
			
			if theCommand is "back" then
				if (do shell script "defaults read com.Colloquy.awayscript 'awayt'") is "" then
					add event message "You were not away"
				end if
				
				if (do shell script "defaults read com.Colloquy.awayscript 'awayt'") is not "" then
					set timestamp to (current date) - (date (do shell script "defaults read com.Colloquy.awayscript 'awayt'"))
					set gonetime to "Gone " & timestamp div hours & " hours, " & timestamp div minutes & " minutes, " & timestamp - (timestamp div minutes * 60) & " seconds."
					tell theView to send message "<strong>is back: </strong>" & gonetime with action tense
					do shell script "defaults write com.Colloquy.awayscript 'awaym' ''"
				end if
			end if
			
		on error (err)
			tell theView to add event message err
		end try
	end process user command
end using terms from