为 ejabberd 创建自定义模块时出错

Error when creating custom module for ejabberd

我在尝试为 ejabberd 创建自定义模块时遇到问题。

使用:
ejabberd 19.05.81(来源)
ubuntu 服务器 18.04

我按照来自的教程创建了 hello_world 模块 https://docs.ejabberd.im/developer/extending-ejabberd/modules/

我尝试将源文件 mod_hello_world.erl 放在 src 文件夹中,然后使用 make install 进行编译。一切顺利,但是如果我在 ejabberd.yml 上添加模块然后启动节点,我会崩溃:

19:59:43.683 [严重] 无法启动 ejabberd 应用程序:选项模块的值无效:'mod_hello_world' 不是 ejabberd 模块

我尝试使用文件夹 $HOME/.ejabberd-modules/sources 和命令 ejabberdctl module_install mod_hello_world,并在检查它是否使用 modules_installed 安装时,它有吗

我仍然遇到上述相同的错误。

有谁知道我做错了什么?

I tried putting the source file mod_hello_world.erl inside the src folder and then compiled using make install. Everything goes smoothly, but if I add the module on ejabberd.yml then start the node, I get a crash:

问题已确认。自 a recent commit, gen_mod requires the ejabberd modules to export four functions。您在 mod_hello_world 源代码中找到的文档页面尚未更新,因此 ejabberd 抱怨它无法将 erlang 模块识别为 ejabberd 模块。感谢您提及!

我已经更新了文档源代码,但我想从下一个版本开始就不会在线更新了。更新后的源代码可以正常使用,请尝试一下:

-module(mod_hello_world).

-behaviour(gen_mod).

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

%% gen_mod API callbacks
-export([start/2, stop/1, mod_options/1, depends/2]).

start(_Host, _Opts) ->
    ?INFO_MSG("Hello, ejabberd world!", []),
    ok.

stop(_Host) ->
    ?INFO_MSG("Bye bye, ejabberd world!", []),
    ok.

depends(_Host, _Opts) ->
    [].

mod_options(_Host) ->
    [].