繁体   English   中英

无法在ejabberd中编译新模块

[英]Can't compile a new module in ejabberd

我正在尝试在erlang中为ejabberd编译一个新模块。我正在学习本教程: http ://jasonrowe.com/2011/12/30/ejabberd-offline-messages

我正在尝试编译此代码:

%% name of module must match file name
-module(mod_http_offline).

-author("Earl The Squirrel").

%% Every ejabberd module implements the gen_mod behavior
%% The gen_mod behavior requires two functions: start/2 and stop/1
-behaviour(gen_mod).

%% public methods for this module
-export([start/2, stop/1, create_message/3]).

%% included for writing to ejabberd log file
-include("ejabberd.hrl").

%% ejabberd functions for JID manipulation called jlib.
-include("jlib.hrl").

start(_Host, _Opt) ->
        post_offline_message("testFrom", "testTo", "testBody"),
        ?INFO_MSG("mod_http_offline loading", []),
        ejabberd_hooks:add(offline_message_hook, _Host, ?MODULE, create_message, 50).  



stop (_Host) ->
        ?INFO_MSG("stopping mod_http_offline", []),
        ejabberd_hooks:delete(offline_message_hook, _Host, ?MODULE, create_message, 50).



create_message(_From, _To, Packet) ->
        Type = xml:get_tag_attr_s("type", Packet),
        FromS = xml:get_tag_attr_s("from", Packet),
        ToS = xml:get_tag_attr_s("to", Packet),
        Body = xml:get_path_s(Packet, [{elem, "body"}, cdata]),
        if (Type == "chat") ->
            post_offline_message(FromS, ToS, Body)
        end.



post_offline_message(From, To, Body) ->
        ?INFO_MSG("Posting From ~p To ~p Body ~p~n",[From, To, Body]),
        ?INFO_MSG("post request sent (not really yet)", []).

我已将jlib.hrl,ejabberd.hrl添加到我的文件夹中。但是当我尝试编译此代码时,我收到以下错误:

jlib.hrl:22: can't find include lib "p1_xml/include/xml.hrl"
mod_http_offline.erl:21: undefined macro 'INFO_MSG/2'
mod_http_offline.erl:27: undefined macro 'INFO_MSG/2'
mod_http_offline.erl:44: undefined macro 'INFO_MSG/2'
jlib.hrl:426: record xmlel undefined
jlib.hrl:466: type xmlel() undefined
mod_http_offline.erl:11: function start/2 undefined
mod_http_offline.erl:11: function stop/1 undefined
mod_http_offline.erl:38: function post_offline_message/3 undefined
mod_http_offline.erl:8: Warning: behaviour gen_mod undefined

我该如何解决这个问题?

我的Ejabberd版本:2.1.11

ejabberd存储库中的jlib.hrl文件包含-include("ns.hrl"). (第21行)和-include_lib("p1_xml/include/xml.hrl"). 第22行.include_lib表示它将在库路径中搜索文件。 您可以修改它并在目录中添加必要的文件(可能是一个简单的测试解决方案吗?)但我认为干净的方法是将tour文件添加到ejabberd应用程序并使用rebar来编译它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM