2
以下是被掛鉤的函數中記錄的數據包之一filter_packet hook。Ejabberd只打印「消息」數據包
I(<0.10945.0>:my_module:46) : in_filter_packet: {xmlelement,"message",
[{"type","headline"}],
[{xmlelement,"event",
[{"xmlns",
"http://jabber.org/protocol/pubsub#event"}],
[{xmlelement,"items",
[{"node",
"http://jabber.org/protocol/tune"}],
[{xmlelement,"item",
[{"id",
"5A487A38503FE"}],
[{xmlelement,"tune",
[{"xmlns",
"http://jabber.org/protocol/tune"}],
[]}]}]}]},
{xmlelement,"addresses",
[{"xmlns",
"http://jabber.org/protocol/address"}],
[{xmlelement,"address",
[{"type","replyto"},
{"jid",
"[email protected]/10042049171444555575238273"}],
[]}]}]}
如何篩選出只有「消息」, 「類型」包?即目前掛鉤功能看起來像
on_filter_packet({From, To, Packet} = Input) ->
?INFO_MSG("in_filter_packet: ~p ", [Packet]), %[gen_mod:get_module_opt(global, ?MODULE, debug, false)]),
Input.
如何寫代碼** if(packet.type == message)only then print **?