<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed><type>rich</type><version>1.0</version><provider_name>phorkie</provider_name><provider_url>https://p.cweiske.de/</provider_url><title>ejabberd: script to send-muc-message</title><author_name>Christian Weiske</author_name><cache_age>86400</cache_age><width>900</width><height>900</height><html>&lt;!-- embedding all files of https://p.cweiske.de/242 --&gt;
&lt;link rel="stylesheet" href="https://p.cweiske.de/css/embed.css"/&gt;
&lt;div class="phork" id="242"&gt;
    &lt;div class="phork-file"&gt;
 &lt;div class="phork-content"&gt;
  &lt;style type="text/css"&gt;&lt;/style&gt;&lt;div class="code"&gt;&lt;table class="erl"&gt;&lt;tbody&gt;&lt;tr class="li1"&gt;&lt;td class="ln"&gt;&lt;pre class="de1"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
&lt;/pre&gt;&lt;/td&gt;&lt;td class="de1"&gt;&lt;pre class="de1"&gt;#!/usr/bin/env escript&#13;
%%! -sname sender@localhost&#13;
%%&#13;
%% Written by Holger Weiss &amp;lt;holger@zedat.fu-berlin.de&amp;gt;.&#13;
%%&#13;
&amp;#160;
%&#13;
% If the node name of your server is not 'ejabberd@localhost' (see the&#13;
% &amp;quot;ejabberdctl status&amp;quot; output), you must change the @localhost part of&#13;
% the node names above and below.&#13;
%&#13;
% Apart from that, you must set Room and Host to the desired values&#13;
% below.&#13;
%&#13;
&amp;#160;
main(Args) -&amp;gt;&#13;
&amp;#160; &amp;#160; Room = &amp;lt;&amp;lt;&amp;quot;test&amp;quot;&amp;gt;&amp;gt;,&#13;
&amp;#160; &amp;#160; Host = &amp;lt;&amp;lt;&amp;quot;conference.example.com&amp;quot;&amp;gt;&amp;gt;,&#13;
&amp;#160; &amp;#160; Node = 'ejabberd@localhost',&#13;
&amp;#160; &amp;#160; Usage = &amp;quot;send-muc-message &amp;lt;message&amp;gt; ...&amp;quot;,&#13;
&amp;#160;
&amp;#160; &amp;#160; Message =&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; case string:join(Args, &amp;quot; &amp;quot;) of&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; [] -&amp;gt;&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; io:format(standard_error, &amp;quot;Usage: ~s~n&amp;quot;, [Usage]),&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; halt(2);&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Joined -&amp;gt;&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; list_to_binary(Joined)&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; end,&#13;
&amp;#160;
&amp;#160; &amp;#160; case rpc:call(Node, mnesia, dirty_read, [muc_online_room, {Room, Host}]) of&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; [R] -&amp;gt;&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Pid = element(3, R),&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; gen_fsm:send_all_state_event(Pid, {service_message, Message});&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; [] -&amp;gt;&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; io:format(standard_error, &amp;quot;Room ~s@~s unavailable~n&amp;quot;, [Room, Host]),&#13;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; halt(1)&#13;
&amp;#160; &amp;#160; end.&#13;
&amp;#160;
% vim:set filetype=erlang tabstop=4 expandtab:&#13;
&amp;#160;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
 &lt;/div&gt;
 &lt;div class="phork-meta"&gt;
  &lt;a href="https://p.cweiske.de/242/rev-raw/41d58a68d95f5117f48886400e8d09d3f815ceb7/phork0.erl" style="float: right"&gt;view raw source&lt;/a&gt;
  &lt;a href="https://p.cweiske.de/242#phork0.erl"&gt;phork0.erl&lt;/a&gt;
 &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</html></oembed>
