ejabberd - Comments for "Question: host_config / &amp;lt;domain&amp;gt; / modules /... how to get parameters ?" https://www.ejabberd.im/forum/25499/question-hostconfig-modules-how-get-parameters en I changed my login.erl file https://www.ejabberd.im/forum/25499/question-hostconfig-modules-how-get-parameters#comment-67334 <p>I changed my login.erl file and compiled my login.erl to get login.beam file.Now when I start my ejabberd I am getting a crash dump as : options: [{key1,&lt;&lt;"bob"&gt;&gt;},{key2,&lt;&lt;"123"&gt;&gt;}] error: {badmatch,&lt;&lt;"bob"&gt;&gt;} [{login,start,2,[{file,"login.erl"},{line,36}]}, and line 36 of login.erl is [EmailId]=proplists:get_value(key1, _Opts), I need my login values to go as login(["bob"],["123"],Pid) but instead I think it is going in as login(["&lt;&gt;"],["&lt;&lt;123&gt;&gt;"],Pid) Am I understanding it correctly or not and what should I do make it work in either case. Thank you in advance.</p> Thu, 23 Feb 2017 08:07:57 +0000 Abhishek Ranjan comment 67334 at https://www.ejabberd.im I have a supervisor https://www.ejabberd.im/forum/25499/question-hostconfig-modules-how-get-parameters#comment-67332 <p>I have a supervisor class<br /> '-module(frequency_sup).</p> <p>-behavior(gen_mod).<br /> -behaviour(supervisor).</p> <p>-export([start_link/0, init/1]).</p> <p>-export([stop/0]).</p> <p>-define(EJABBERD_DEBUG, true).</p> <p>-export([<br /> start/2,<br /> stop/1,<br /> process/2<br /> ]) .</p> <p>-include("ejabberd.hrl").<br /> -include("jlib.hrl").<br /> -include("ejabberd_http.hrl").</p> <p>start(_Host, _Opts) -&gt; ok.<br /> stop(_Host) -&gt; ok.</p> <p>process(_Path, _Request) -&gt;<br /> {xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"}],<br /> [{xmlelement, "head", [],<br /> [{xmlelement, "title", [], []}]},<br /> {xmlelement, "body", [],<br /> [{xmlelement, "p", [], [{xmldata, start_link()}]}]}]},<br /> "frequency has started".</p> <p>start_link() -&gt;</p> <p> Pid=supervisor:start_link({local,?MODULE},?MODULE, []).</p> <p>stop() -&gt; exit(whereis(?MODULE), shutdown).</p> <p>init(_) -&gt;</p> <p> ChildSpecList = [ child(myMainModule)],</p> <p> {ok,{{rest_for_one, 2, 3600}, ChildSpecList}}.</p> <p>child(Module) -&gt;</p> <p> {Module, {Module, start, []},</p> <p> temporary, 2000, worker, [Module]}.</p> <p> I am using process/2 function with parameters "path and "request" respectively,and I have configured my ejabberd.yml file in module section as modules: frequency_sup: {}` and</p> <p>port: 5280<br /> module: ejabberd_http<br /> request_handlers:<br /> "frequency": frequency_sup<br /> "/websocket": ejabberd_http_ws<br /> ## "/pub/archive": mod_http_fileserver<br /> web_admin: true<br /> http_bind: true<br /> ## register: true<br /> captcha: false<br /> now when i call this function with this url localhost:5280/frequency_sup it generates the pid and I can monitor this in ejabberdctl live. but in my next step i need to login in another module which takes three parameters like login([EmailId],[Password],pid) and this is where I am having trouble with two things 1.that how to use the Pid that i generated via first url call of frequency_sup in the second function call of login and 2.as you can see I need to pass emailid and password to call login function,how to do that as each time a new user logs in he will pass different parameters and if i will write it into the ejabberd.yml file like login:<br /> {EmailId: "bob"<br /> Password: "123"}</p> <p>then it will only work for custom cases. I have a feeling that it can be solved by the help of the _request parameter of the process module but i haven't found any good blogs explaining that can anybody help me with this. thank you in advance</p> Wed, 22 Feb 2017 13:04:36 +0000 Abhishek Ranjan comment 67332 at https://www.ejabberd.im Self replied. RTFM and source https://www.ejabberd.im/forum/25499/question-hostconfig-modules-how-get-parameters#comment-66921 <p>Self replied.<br /> RTFM and source code !</p> <pre> gen_mod:get_module_opt(global, mymodule, property, fun(A)-&gt;A end). </pre><p>atom 'global' is my friend :)</p> <p>Ben</p> Fri, 10 Jun 2016 10:02:51 +0000 andrea comment 66921 at https://www.ejabberd.im Thanks vipulpachauri, I'm now https://www.ejabberd.im/forum/25499/question-hostconfig-modules-how-get-parameters#comment-66920 <p>Thanks vipulpachauri,<br /> I'm now using gen_mod:get_module_opt and similar functions from gen_mod to get all from them.</p> <p>I also would like to know another thing:<br /> what if I have a module with options declared globally (not related to a specific host) ?<br /> here's an example:</p> <pre> modules: mymodule: property: "value" </pre><p>This is not related to a single host but the module is declared globally.<br /> How can I get "property" without specifying the host name ?</p> <p>gen_mod:get_module_opt() needs to have an host to work</p> <p>Thanks again,<br /> Ben</p> Fri, 10 Jun 2016 09:59:02 +0000 andrea comment 66920 at https://www.ejabberd.im Friend, You need to create a https://www.ejabberd.im/forum/25499/question-hostconfig-modules-how-get-parameters#comment-66919 <p>Friend, You need to create a module and add that module in ejabberd config file. In that module you have to specify your command to get list of "param1" like others ejabberd command. e.g. get list of all registered users. "sudo ejabberdctl registered_users user localhost"</p> <p>I suggest you to view "mod_admin_extra.erl" and go through this link for better understanding of modules <noindex><a href="http://learnyousomeerlang.com/introduction" title="http://learnyousomeerlang.com/introduction" rel="nofollow" >http://learnyousomeerlang.com/introduction</a></noindex></p> Fri, 10 Jun 2016 07:55:01 +0000 vipulpachauri comment 66919 at https://www.ejabberd.im