--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/mc_mood.lua Fri Mar 27 12:06:19 2009 +0200
@@ -0,0 +1,45 @@
+
+local lm = require 'lm'
+local mood = require 'mood'
+local pubsub = require 'pubsub'
+
+pubsub.handler ( 'http://jabber.org/protocol/mood',
+ function ( from, node, data )
+ if not main.yesno ( main.option ( 'lua_pep_notification' ) ) then
+ return true
+ end
+ local item = data:child ()
+ local mood, desc
+ while item do
+ if item:name () == 'text' then
+ desc = item:value ()
+ else
+ mood = item:name ()
+ -- here we can add child elements handling (by namespace)
+ end
+ item = item:next ()
+ end
+ if mood then
+ main.print_info ( from, ("Buddy's mood now %s %s"):format ( mood, desc or '' ) )
+ else
+ main.print_info ( from, "Buddy hides his mood" )
+ end
+ end )
+
+main.command ( 'mood',
+ function ( args )
+ mood.publish ( lm.connection.bless ( main.connection () ),
+ function ()
+ print ( 'Mood published' )
+ end,
+ function ( mesg )
+ print ( 'Error publishing mood: ' .. mesg )
+ end, args[1], args[2] )
+ end, true )
+
+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."
+
+main.add_feature ( 'http://jabber.org/protocol/mood+notify' )
+main.add_feature ( 'http://jabber.org/protocol/mood' )
+
+-- vim: se ts=4: --