examples/mc_avatar.lua
changeset 68 742878c74b8e
parent 67 d33ca5572e91
child 69 ab6d4ee8974c
--- a/examples/mc_avatar.lua	Sat Mar 28 19:43:12 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-
-local lm     = require 'lm'
-local pubsub = require 'pubsub'
-local avatar = require 'avatar'
-
-pubsub.handler ( 'urn:xmpp:avatar:metadata',
-	function ( from, node, data, id )
-		if not main.yesno ( main.option ( 'lua_pep_notification' ) ) then
-			return true
-		end
-		local item = data:child ()
-		while item do
-			main.print_info ( from, ('Avatar: %s [%s] %s bytes, %sx%s %s'):format (
-					item:attribute ( 'id' ),
-					item:attribute ( 'type' ),
-					item:attribute ( 'bytes' ),
-					item:attribute ( 'width' ) or '?',
-					item:attribute ( 'height' ) or '?',
-					item:attribute ( 'url' ) or '' ) )
-			item = item:next ()
-		end
-	end )
-
-main.command ( 'avatar',
-	function ( args )
-		local action = args[1]
-		if action == 'get' then
-			local who
-			if args.t then
-				who = args.t
-			else
-				who = main.current_buddy ()
-			end
-			avatar.get ( lm.connection.bless ( main.connection () ), who, args[2],
-				function ( data )
-					local h = io.open ( args[3], 'w' )
-					if h then
-						h:write ( data )
-						h:close ()
-						main.print_info ( who, 'Avatar saved to ' .. args[3] )
-					else
-						print ( 'Cannot open file for writing ' .. args[3] )
-					end
-				end,
-				function ( mesg )
-					main.print_info ( who, 'Error obtaining avatar: ' .. mesg )
-				end )
-		else
-			local file = action
-			if action == 'set' then
-				file = args[2]
-			end
-			local h = io.open ( file )
-			if h then
-				data = h:read ( '*a' )
-				h:close ()
-				avatar.publish ( lm.connection.bless ( main.connection () ), data,
-					function ()
-						print ( 'Avatar published' )
-					end,
-					function ( mesg )
-						print ( 'Avatar publishing error: ' .. mesg )
-					end )
-			else
-				print ( 'Cannot open file ' .. file )
-			end
-		end
-	end, true, 'file' )
-
-commands_help['avatar'] = '[-t jid] get id filename | [set] filename\n\nGet action tries to get from server avatar with specified id and save it to \'filename\'.\nSet action publishes avatar to server. File must be a PNG image.'
-
-main.add_feature ( 'urn:xmpp:avatar:metadata+notify' )
-
--- vim: se ts=4: --