ejabberd - Comments for "how to get users &amp;quot;os&amp;quot; in module mod_muc_room" https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom en How can I do it? thnx. https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66287 <p>How can I do it? thnx.</p> Tue, 03 Nov 2015 15:13:52 +0000 davai comment 66287 at https://www.ejabberd.im Hi; Thank u I edited https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66290 <p>Hi;</p> <p>Thank u</p> <p>I edited <code>mod_muc_room</code> like what u say</p> <p>and add get_os function</p> <div class="codeblock"><code>%% get OS<br />get_os(Packet) -&gt;<br /> Q = xml:get_subtag(Packet, &quot;query&quot;),<br /> O = xml:get_subtag(Q, &quot;os&quot;),<br /> {ok, xml:get_tag_cdata(O)}.</code></div> <p>trying :</p> <div class="codeblock"><code>&nbsp;&nbsp;&nbsp; Os = case catch get_os(Packet) of<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {ok, Result} -&gt; Result;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ -&gt; not_iq_version<br />&nbsp;&nbsp;&nbsp; end,<br />&nbsp;&nbsp;&nbsp; ?INFO_MSG(&quot;OS is : ~p&quot;, [OS]),</code></div> <p>also trying :</p> <div class="codeblock"><code>&nbsp;&nbsp;&nbsp; Os = case catch get_os(Packet) of<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {ok, Result} -&gt; Result;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ -&gt; not_iq_version<br />&nbsp;&nbsp;&nbsp; end,<br />&nbsp;&nbsp;&nbsp; ?WARNING_MSG(&quot;OS is : ~p&quot;, [OS]),</code></div> <p>so I run Ejabberd : <code>ejabberdctl live</code>. and when I'm joining to room no thing show to me in terminal.</p> <p>I'm using Ejabberd 2.1.x</p> Tue, 03 Nov 2015 14:37:30 +0000 davai comment 66290 at https://www.ejabberd.im I'm using ejabberd 15.09. The https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66245 <p>I'm using ejabberd 15.09. The code is similar for older versions, you can reuse it.</p> <p>This patch:</p> <pre> --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -618,6 +618,11 @@ normal_state({route, From, ToNick, StateData) -&gt; Lang = xml:get_attr_s(&lt;&lt;"xml:lang"&gt;&gt;, Attrs), StanzaId = xml:get_attr_s(&lt;&lt;"id"&gt;&gt;, Attrs), + Os = case catch get_os(Packet) of + {ok, Result} -&gt; Result; + _ -&gt; not_iq_version + end, + ?INFO_MSG("Os: ~p", [Os]), case {(StateData#state.config)#config.allow_query_users, is_user_online_iq(StanzaId, From, StateData)} of @@ -4539,3 +4544,7 @@ has_body_or_subject(Packet) -&gt; (_) -&gt; true end, Packet#xmlel.children). +get_os(Packet) -&gt; + Q = xml:get_subtag(Packet, &lt;&lt;"query"&gt;&gt;), + O = xml:get_subtag(Q, &lt;&lt;"os"&gt;&gt;), + {ok, xml:get_tag_cdata(O)}. </pre><p> And I get something like this in the log:</p> <pre> 12:15:58.841 [info] ({socket_state,gen_tcp,#Port&lt;0.8631&gt;,&lt;0.507.0&gt;}) Accepted legacy authentication for user1@localhost/tka1 by ejabberd_auth_internal from 127.0.0.1 12:16:06.458 [info] Os: not_iq_version 12:16:06.461 [info] Os: not_iq_version 12:16:06.466 [info] Os: not_iq_version 12:16:06.466 [info] Os: not_iq_version 12:16:06.471 [info] Os: &lt;&lt;"Debian GNU/Linux 8.1 (jessie) 8.1 jessie 4.1.0-2-amd64"&gt;&gt; 12:16:06.472 [info] Os: not_iq_version 12:16:06.475 [info] Os: not_iq_version 12:16:06.477 [info] Os: not_iq_version </pre> Mon, 19 Oct 2015 10:18:05 +0000 badlop comment 66245 at https://www.ejabberd.im Hi; Sorry for late. Xmpp https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66225 <p>Hi;</p> <p>Sorry for late.</p> <p>Xmpp packet like this :</p> <div class="codeblock"><code>&lt;query xmlns=&#039;http://jabber.org/protocol/disco#info&#039;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node=&#039;http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w=&#039;&gt;<br />&nbsp;&nbsp;&nbsp; &lt;identity xml:lang=&#039;en&#039; category=&#039;client&#039; name=&#039;Psi 0.11&#039; type=&#039;pc&#039;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;identity xml:lang=&#039;el&#039; category=&#039;client&#039; name=&#039;Ψ 0.11&#039; type=&#039;pc&#039;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;feature var=&#039;http://jabber.org/protocol/caps&#039;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;feature var=&#039;http://jabber.org/protocol/disco#info&#039;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;feature var=&#039;http://jabber.org/protocol/disco#items&#039;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;feature var=&#039;http://jabber.org/protocol/muc&#039;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;x xmlns=&#039;jabber:x:data&#039; type=&#039;result&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field var=&#039;FORM_TYPE&#039; type=&#039;hidden&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;urn:xmpp:dataforms:softwareinfo&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field var=&#039;ip_version&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;ipv4&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;ipv6&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field var=&#039;os&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;Windows 8.1&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field var=&#039;os_version&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;10.5.1&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field var=&#039;software&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;Psi&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/field&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field var=&#039;software_version&#039;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;0.11&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/field&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/x&gt;<br />&lt;/query&gt;</code></div> <p>What I'm looking for is get os like : Windows 8.1</p> <div class="codeblock"><code>&lt;field var=&#039;os&#039;&gt;<br />&nbsp;&nbsp; &lt;value&gt;Windows 8.1&lt;/value&gt;&lt;</code></div> Fri, 16 Oct 2015 01:15:43 +0000 davai comment 66225 at https://www.ejabberd.im An XMPP Packet is the basis https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66188 <p>An XMPP Packet is the basis of XMPP protocol. You should read more on xmpp.org.</p> Mon, 05 Oct 2015 09:20:24 +0000 mremond comment 66188 at https://www.ejabberd.im mremond wrote: It would be https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66156 <div class="quote-msg"> <div class="quote-author"><em>mremond</em> wrote:</div> <p>It would be easier to help if you could show the XMPP packet you are trying to parse. Can you please do that ?</p></div> <p>Hi;</p> <p>The idea is like any bot (iSida, gluxi, sulci ... etc) if u type to him this : <code>version mremond</code></p> <p>it'll send u your version information like --&gt;</p> <div class="codeblock"><code>name : Psi+<br />ver : 1.1<br />os : windows 8.1</code></div> <p><strong>Example</strong> --&gt; I need this os : <code>windows 8.1</code> to print it when mremond joining the room, I need to definition the OS</p> <p>I don't know what do u mean the XMPP packet in this case can u explain me with some example please!</p> <p><strong>thank u</strong></p> Wed, 30 Sep 2015 22:01:04 +0000 davai comment 66156 at https://www.ejabberd.im It would be easier to help if https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66152 <p>It would be easier to help if you could show the XMPP packet you are trying to parse. Can you please do that ?</p> Wed, 30 Sep 2015 16:18:50 +0000 mremond comment 66152 at https://www.ejabberd.im mremond wrote: More https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66149 <div class="quote-msg"> <div class="quote-author"><em>mremond</em> wrote:</div> <p>More specifically: Is your code crashing ? Is your OS tag not found ? What is your original XMPP packet looking like exactly ?</p></div> <p>Hi;</p> <p>yes, OS tag not found. because nothing shown on terminal when I join.<br /> <strong>I think this : </strong><code>OS = xml:get_subtag_cdata(Packet, &quot;os&quot;),</code><strong> not the correct way to definition the OS</strong></p> Tue, 29 Sep 2015 20:08:08 +0000 davai comment 66149 at https://www.ejabberd.im More specifically: Is your https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66145 <p>More specifically: Is your code crashing ? Is your OS tag not found ? What is your original XMPP packet looking like exactly ?</p> Tue, 29 Sep 2015 07:21:00 +0000 mremond comment 66145 at https://www.ejabberd.im mremond wrote: What does not https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66138 <div class="quote-msg"> <div class="quote-author"><em>mremond</em> wrote:</div> <p>What does not work ? What are you trying to achieve ?</p></div> <p>I'm trying to define OS in mod_muc_room to get user's OS before joining room and print it.</p> Sun, 27 Sep 2015 23:46:29 +0000 davai comment 66138 at https://www.ejabberd.im What does not work ? What are https://www.ejabberd.im/forum/25119/how-get-users-os-module-modmucroom#comment-66119 <p>What does not work ? What are you trying to achieve ?</p> Thu, 24 Sep 2015 08:57:11 +0000 mremond comment 66119 at https://www.ejabberd.im