Toggle status function
authorMyhailo Danylenko <isbear@ukrpost.net>
Sun, 01 Mar 2009 18:35:16 +0200
changeset 12 a52d61f57e0d
parent 11 f74fff438888
child 13 0b716ba23b03
Toggle status function
examples/mcabberrc.lua
--- a/examples/mcabberrc.lua	Fri Feb 27 21:57:56 2009 +0200
+++ b/examples/mcabberrc.lua	Sun Mar 01 18:35:16 2009 +0200
@@ -200,7 +200,8 @@
 	exthelp   = "[command]\n\nPrints help for a given command, or list of available help topics.",
 	reload    = "\n\nJust a shorthand to reload lua config file. Note, that for now this discards all changes to configuration, open forms, transferred files.",
 	['join!'] = "\n\nForcibly joins to current buddy. Just saves you typing of full room name (that can be quite long) in a case of a non-bookmarked rooms.",
-	count     = "\n\nPrints number of resources of current buddy. Useful to determine member count of large room."
+	count     = "\n\nPrints number of resources of current buddy. Useful to determine member count of large room.",
+	toggle    = "\n\nToggles away/online status.",
 }
 
 main.command ( 'post',
@@ -255,6 +256,15 @@
 		end
 		print ( "Resource count: " .. count )
 	end )
+main.command ( 'toggle',
+	function ( args )
+		local stat, mess = main.status ()
+		if stat == 'o' then
+			main.run ( 'status away ' .. mess )
+		else
+			main.run ( 'status online ' .. mess )
+		end
+	end )
 
 -- commands to allow leading smileys
 for k, arg in ipairs ( { ')', '/', '(', 'D', '-/', 'S', '1', ']', '[' } ) do