Create new ejabberdctl command

Dear All,
I have developed my own ejabberd module, but i don't know how to register my own command with ejabberdctl, i have tried to follow in the ejabberd_admin.erl but the command is not appear in the ejabberdctl console, is there something am i missing ?

-include_lib("stdlib/include/ms_transform.hrl").
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_commands.hrl").
-include("ejabberd_sql_pt.hrl").
-include("jlib.hrl").

-export([init/1, iunblockotp/2, get_commands_spec/0, terminate/2]).
init([]) ->
    process_flag(trap_exit, true),
    ejabberd_commands:register_commands(get_commands_spec()),
    {ok, #state{}}.

terminate(_Reason, _State) ->
    ejabberd_commands:unregister_commands(get_commands_spec()).

%%%
%%% ejabberd commands
%%%

get_commands_spec() ->
	[
     %% The commands status, stop and restart are implemented also in ejabberd_ctl
     %% They are defined here so that other interfaces can use them too
     #ejabberd_commands{name = iunblockotp, tags = [accounts],
			desc = "Unblock OTP",
            policy = admin,
			module = ?MODULE, function = iunblockotp,
			args_desc = ["Username", "Local vhost served by ejabberd"],
			args_example = [<<"bob">>, <<"example.com">>],
			args = [{user, binary}, {host, binary}],
			result = {res, restuple}}
    ].

iunblockotp(User, Server) ->
	ejabberd_sql:sql_query(

Please help.

You must call init/0, so the

You must call init/0, so the command gets registered in ejabberd list of commands

Ok, thanks. Actually i was

Ok, thanks. Actually i was using gen_mod behaviour so i need to trigger it in start function.

Syndicate content