examples/room_priv.lua
changeset 8 fc9060b9b7cc
child 9 c2517f8bf647
equal deleted inserted replaced
7:eb6d89bf1fbf 8:fc9060b9b7cc
       
     1 
       
     2 -- ROOM NICK COMPLETION
       
     3 
       
     4 room_cid = main.command ( 'priv',
       
     5 	function ( args )
       
     6 		main.run ( 'room privmsg ' .. args )
       
     7 	end, {} )
       
     8 
       
     9 commands_help['priv'] = "nick message\n\nSends private message to room participant. Nick completion available! ;)"
       
    10 
       
    11 registered_nicks = {}
       
    12 
       
    13 function register_nicks ()
       
    14 	for k, nick in pairs ( registered_nicks ) do
       
    15 		main.del_completion ( room_cid, nick )
       
    16 	end
       
    17 	local buddy = main.current_buddy ()
       
    18 	if buddy then
       
    19 		local info = main.buddy_info ( buddy )
       
    20 		if info then
       
    21 			registered_nicks = { }
       
    22 			if info.type == 'room' then
       
    23 				for nick, k in pairs ( info.resources ) do
       
    24 					main.add_completion ( room_cid, nick )
       
    25 					table.insert ( registered_nicks, nick )
       
    26 				end
       
    27 			end
       
    28 		end
       
    29 	end
       
    30 end
       
    31 
       
    32 main.run ( 'bind 338 = lua main.run ( "roster down" ); register_nicks ()' )
       
    33 main.run ( 'bind 339 = lua main.run ( "roster up" ); register_nicks ()' )
       
    34 
       
    35 -- vim: se ts=4: --