examples/xep0163.lua
changeset 24 25552b21d3fb
parent 23 e441162b1386
child 26 fc83934f9b8d
equal deleted inserted replaced
23:e441162b1386 24:25552b21d3fb
   267 			enable_tune ( enable )
   267 			enable_tune ( enable )
   268 		end
   268 		end
   269 	end, boolean_cid )
   269 	end, boolean_cid )
   270 main.command ( 'mood',
   270 main.command ( 'mood',
   271 	function ( args )
   271 	function ( args )
       
   272 		args = parse_args ( args )
   272 		local data = { }
   273 		local data = { }
   273 		local mood, text = args:match ( "(%S-)%s+(.+)" )
   274 		local mood, text = args[1], args[2]
   274 		if mood then
   275 		if text then
   275 			data.text  = { text }
   276 			data.text  = { text }
   276 		else
       
   277 			mood = args
       
   278 		end
   277 		end
   279 		if mood ~= '' then
   278 		if mood ~= '' then
   280 			data[mood] = { }
   279 			data[mood] = { }
   281 		end
   280 		end
   282 		pep_publish ( 'mood', data )
   281 		pep_publish ( 'mood', data )
   283 	end )
   282 	end )
   284 main.command ( 'activity',
   283 main.command ( 'activity',
   285 	function ( args )
   284 	function ( args )
       
   285 		args = parse_args ( args )
   286 		local data = { }
   286 		local data = { }
   287 		local activity, text = args:match ( "(%S-)%s+(.+)" )
   287 		local activity, text = args[1], args[2]
   288 		if activity then
   288 		if text then
   289 			data.text = { text }
   289 			data.text = { text }
   290 		else
   290 		end
   291 			activity = args
   291 		local act, subact = activity:match ( "(.-)%-(.+)" )
   292 		end
       
   293 		local act, subact = activity:match ( ".-%-.+" )
       
   294 		if not act then
   292 		if not act then
   295 			act = activity
   293 			act = activity
   296 		end
   294 		end
   297 		if act ~= '' then
   295 		if act ~= '' then
   298 			data[act] = { }
   296 			data[act] = { }
   302 		end
   300 		end
   303 		pep_publish ( 'activity', data )
   301 		pep_publish ( 'activity', data )
   304 	end )
   302 	end )
   305 main.command ( 'location',
   303 main.command ( 'location',
   306 	function ( args )
   304 	function ( args )
       
   305 		args = parse_args ( args )
   307 		local data = { }
   306 		local data = { }
   308 		local key, val, remains = args:match ( '%s*(%S+)%s+(%S+)(.*)' )
   307 		for key, val in pairs ( args ) do
   309 		while key do
       
   310 			data[key] = { val }
   308 			data[key] = { val }
   311 			key, val, remains = args:match ( '%s*(%S+)%s+(%S+)(.*)' )
       
   312 		end
   309 		end
   313 		pep_publish ( 'geoloc', data )
   310 		pep_publish ( 'geoloc', data )
   314 	end )
   311 	end )
   315 
   312 
   316 commands_help['tune']     = "[enable|disable|on|off|yes|no|true|false]\n\nEnables or disables publishing of notifications about playing music in your player (currently only mpd is supported)."
   313 commands_help['tune']     = "[enable|disable|on|off|yes|no|true|false]\n\nEnables or disables publishing of notifications about playing music in your player (currently only mpd is supported)."
   317 commands_help['mood']     = "[mood [message]]\n\nPublishes your mood.\nNote, that for now it does not checks for mood validity, so, see xep0107 for valid moods."
   314 commands_help['mood']     = "[mood [message]]\n\nPublishes your mood.\nNote, that for now it does not checks for mood validity, so, see xep0107 for valid moods."
   318 commands_help['activity'] = "[activity[-specific_activity] [text]]\n\nPublishes your activity.\nNote, that for now it does not checks for activity validity, so, see xep0108 for valid activity values."
   315 commands_help['activity'] = "[activity[-specific_activity] [text]]\n\nPublishes your activity.\nNote, that for now it does not checks for activity validity, so, see xep0108 for valid activity values."
   319 commands_help['location'] = "[key value [key value ...]]\n\nPublishes your current geolocation.\nValid keys are accuracy, alt, area, bearing, building, country, datum, description, error, floor, lat, locality, lon, postalcode, region, room, speed, street, text, timestamp and uri, according to xep0080."
   316 commands_help['location'] = "[-key value [-key value ...]]\n\nPublishes your current geolocation.\nValid keys are accuracy, alt, area, bearing, building, country, datum, description, error, floor, lat, locality, lon, postalcode, region, room, speed, street, text, timestamp and uri, according to xep0080."
   320 
   317 
   321 pep_handler_registered = false
   318 pep_handler_registered = false
   322 
   319 
   323 hooks_d['hook-post-connect'].xep0163 =
   320 hooks_d['hook-post-connect'].xep0163 =
   324 	function ( args )
   321 	function ( args )