--- a/TODO Mon Mar 23 08:15:47 2009 +0200
+++ b/TODO Mon Mar 23 09:22:04 2009 +0200
@@ -21,4 +21,5 @@
test node config
publish library handlers?
fix add_feature to 1) not add existing items 2) not add default items
+check all that callbacks for empty 'to' fields in print_info
--- a/examples/evil.lua Mon Mar 23 08:15:47 2009 +0200
+++ b/examples/evil.lua Mon Mar 23 09:22:04 2009 +0200
@@ -52,8 +52,13 @@
evil.handler =
function ( mess )
+ local evillevel = tonumber(main.option ( 'lua_evil_sensibility' ))
local mtype, smtype = mess:type ()
- main.print_info ( mess:attribute ( 'from' ), 'Evil stanza of type ' .. mtype .. ', ' .. ( smtype or '' ) .. ' detected!' )
+ if evillevel > 1 then
+ main.print_info ( mess:attribute ( 'from' ), 'Evil stanza of type "' .. mtype .. ' ' .. smtype .. '" detected!' )
+ elseif evillevel > 0 then
+ print ( 'Tainted by evil stanza of type "' .. mtype .. ' ' .. smtype .. '" from ' .. ( mess:attribute ( 'from' ) or '... unknown in black' ) )
+ end
return main.yesno ( main.option ( 'lua_filter_evil' ) )
end
@@ -66,7 +71,6 @@
offline = 'unavailable',
}
-
-- TODO improve interface, check if we sending right thing for offline
main.command ( 'evil',
function ( args )
@@ -116,21 +120,38 @@
hooks_d['hook-post-connect'].evil =
function ( args )
- lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'iq', 'normal' )
- lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'message', 'normal' )
- lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'presence', 'normal' )
+ lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'iq', 'first' )
+ lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'message', 'first' )
+ lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'presence', 'first' )
evil_handler_registered = true
hooks_d['hook-post-connect'].evil = nil
hooks_d['hook-quit'].evil =
function ( args )
if evil_handler_registered then
- lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'iq' )
- lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'message' )
+ lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'iq' )
+ lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'message' )
lm.connection.bless( main.connection () ):handler ( evil_incoming_stanza_handler, 'presence' )
end
end
end
+local char2xmpp = {
+ f = 'chat',
+ o = '',
+ a = 'away',
+ d = 'dnd',
+ n = 'xa',
+ _ = 'unavailable',
+}
+
+-- hack, but working ;)
+hooks_d['hook-my-status-change'].evil =
+ function ( args )
+ if main.yesno ( main.option ( 'lua_evil_mode' ) ) then
+ evil.presence ( lm.connection.bless ( main.connection () ), nil, char2xmpp[args.new_status], args.message )
+ end
+ end
+
main.add_feature ( 'http://jabber.org/protocol/evil' )
-- vim: se ts=4: --
--- a/examples/lua.rc Mon Mar 23 08:15:47 2009 +0200
+++ b/examples/lua.rc Mon Mar 23 09:22:04 2009 +0200
@@ -20,5 +20,14 @@
# XXX additional path to allow non-system loading of lua-lm
set lua_extra_include = ~/.mcabber
+# send evil presence
+set lua_evil_mode = 0
+
+# 0 ignore, 1 print to log, 2 print to buddy's buffer
+set lua_evil_sensibility = 1
+
+# filter evil stanzas
+set lua_filter_evil = 0
+
load mcabber-lua