Applescript to sign out of imessage

I need a simple script to just quickly sign me out of imessage. I use it at work…I need a way for my kids and wife to get in touch with me quickly and don’t need to have my phone out at work. However, sometimes I may be away from laptop sometimes as well, and would like to have a way to quickly sign out with one click.
Is that possible with an Apple Script? I search the forum already and found nothing…and searched via Google before coming here.

To get you started:

tell application "Messages"
	set serviceList to properties of every service	
	repeat with i in serviceList
		if (service type of i as text) contains "iMessage" then
			log enabled of i
			set enabled of i to false
		end if
	end repeat
end tell


Not quite logging out, but essentially the same. Change Bonjour for

If stuck, open script editor, then click “File” then “Open Dictionary”. Find “Messages” for more help