examples/remote.lua
changeset 99 ed4676536ed9
parent 68 742878c74b8e
child 121 75a7d595817c
equal deleted inserted replaced
98:59aeae623ac6 99:ed4676536ed9
     2 local lm     = require 'lm'
     2 local lm     = require 'lm'
     3 local remote = require 'lm.remote'
     3 local remote = require 'lm.remote'
     4 
     4 
     5 main.command ( 'remote',
     5 main.command ( 'remote',
     6 	function ( args )
     6 	function ( args )
       
     7 		local connection = main.connection ()
       
     8 		if not connection then
       
     9 			print "You are not online!"
       
    10 			return
       
    11 		end
     7 		local who
    12 		local who
     8 		if args.t then
    13 		if args.t then
     9 			who = args.t
    14 			who = args.t
    10 		else
    15 		else
    11 			who = main.full_jid ()
    16 			who = main.full_jid ()
    12 		end
    17 		end
    13 		local action = args[1]
    18 		local action = args[1]
    14 		local conn   = lm.connection.bless ( main.connection () )
    19 		local conn   = lm.connection.bless ( connection )
    15 		if action then
    20 		if action then
    16 			remote.command ( conn, who, action,
    21 			remote.command ( conn, who, action,
    17 				function ( form, submit, reject )
    22 				function ( form, submit, reject )
    18 					if not form then
    23 					if not form then
    19 						main.print_info ( who, ('Command %s completed'):format ( action ) )
    24 						main.print_info ( who, ('Command %s completed'):format ( action ) )
    61 		end
    66 		end
    62 	end, true, 'jid' )
    67 	end, true, 'jid' )
    63 
    68 
    64 commands_help['remote'] = "[-t target_jid] [remote_command]\n\nPrints list of available remote command or requests execution of specified command."
    69 commands_help['remote'] = "[-t target_jid] [remote_command]\n\nPrints list of available remote command or requests execution of specified command."
    65 
    70 
    66 -- vim: se ts=4: --
    71 -- vim: se ts=4 sw=4: --