0

我正在尝试为 ejabberd 17.01 编写模块。它一直在开发 ejabberd 16.08。

我用包安装程序安装了 ejabberd。

-module(mod_imran_offline).
-author('igggg').

-behaviour(gen_mod).

%% Required by ?INFO_MSG macros
-include("logger.hrl").

-export([start/2, stop/1,on_offline/4]).

start(_Host, _Opts) ->
    ?INFO_MSG("Hello, ejabberd world!", []),
    ejabberd_hooks:add(offline_message_hook, _Host, ?MODULE, on_offline, 10),
    ok.

stop(_Host) ->
    ?INFO_MSG("Bye bye, ejabberd world!", []),
    ejabberd_hooks:delete(offline_message_hook, _Host, ?MODULE, on_offline, 10),
    ok.

on_offline(_User, _Server, _Resource, _Packet) ->
    ?INFO_MSG("Posting From ~p Body ~p~n",[_User, _Packet]),
    none.

我在日志中收到以下错误

=====================================

2017-02-09 05:36:45.825 [错误] <0.660.0>@ejabberd_hooks:run1:332 {undef,[{mod_offline_test,on_offline,[{jid,<<"FROM-JID">>,<<"我的服务器名称">>,<<"资源">>,<<"FROM-JID">>,<<"我的服务器名称">>,<<"资源">>},{jid ,<<"TO-JID">>,<<"MY-SERVER-NAME">>,<<>>,<<"TO-JID">>,<<"MY-SERVER-NAME">>, <<>>},{消息,<<"B094705E-3F0B-4AA2-9630-C5A6DEEE7033">>,聊天,<<>>,{jid,<<"FROM-JID">>,<<"MY-服务器名">>,<<"资源">>,<<"FROM-JID">>,<<"我的服务器名">>,<<"资源">>},{jid,<<"TO-JID">>,<<"MY-SERVER-NAME">>,<<>>,<<"TO-JID">>,<<"MY -SERVER-NAME">>,<<>>},[],[{text,<<>>,<<"Rrrrrrr">>}],未定义,[],#{}}],[]} ,{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run1,3,[{file,"src/ejabberd_hooks.erl"},{ line,329}]},{ejabberd_sm,route,3,[{file,"src/ejabberd_sm.erl"},{line,126}]},{ejabberd_local,route,3,[{file,"src/ejabberd_local .erl"},{line,110}]},{ejabberd_router,route,3,[{file,"src/ejabberd_router.erl"},{line,87}]},{ejabberd_c2s,check_privacy_route,5,[{文件,"src/ejabberd_c2s.erl"},{line,1886}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1170}]}]} 运行钩子:{offline_message_hook,[{jid,<<"FROM-JID">>,<<"MY-SERVER-NAME">>,< <"RESOURCE">>,<<"FROM-JID">>,<<"MY-SERVER-NAME">>,<<"RESOURCE">>},{jid,<<"TO-JID">> ,<<"我的服务器名称">>,<<>>,<<"TO-JID">>,<<"我的服务器名称">>,<<>>},{消息,< <"B094705E-3F0B-4AA2-9630-C5A6DEEE7033">>,聊天,<<>>,{jid,<<"FROM-JID">>,<<"MY-SERVER-NAME">>,<<"资源">>,<<"FROM-JID">>,<<"MY-SERVER-NAME">>,<<"资源">>},{jid,<<"TO-JID">>,<<"MY-SERVER-NAME">>,<<>>,<<"TO-JID">>,<<"MY-SERVER-NAME">>,< <>>},[],[{文本,<<>>,<<"Rrrrrrr">>}],未定义,[],#{}}]}

=====================================

4

1 回答 1

0

你应该返回数据包而不是无

于 2017-03-28T08:28:54.983 回答