(no commit message)
[paste/242.git] / phork0.erl
1 #!/usr/bin/env escript\r
2 %%! -sname sender@localhost\r
3 %%\r
4 %% Written by Holger Weiss <holger@zedat.fu-berlin.de>.\r
5 %%\r
6 \r
7 %\r
8 % If the node name of your server is not 'ejabberd@localhost' (see the\r
9 % "ejabberdctl status" output), you must change the @localhost part of\r
10 % the node names above and below.\r
11 %\r
12 % Apart from that, you must set Room and Host to the desired values\r
13 % below.\r
14 %\r
15 \r
16 main(Args) ->\r
17     Room = <<"test">>,\r
18     Host = <<"conference.example.com">>,\r
19     Node = 'ejabberd@localhost',\r
20     Usage = "send-muc-message <message> ...",\r
21 \r
22     Message =\r
23         case string:join(Args, " ") of\r
24             [] ->\r
25                 io:format(standard_error, "Usage: ~s~n", [Usage]),\r
26                 halt(2);\r
27             Joined ->\r
28                 list_to_binary(Joined)\r
29         end,\r
30 \r
31     case rpc:call(Node, mnesia, dirty_read, [muc_online_room, {Room, Host}]) of\r
32         [R] ->\r
33             Pid = element(3, R),\r
34             gen_fsm:send_all_state_event(Pid, {service_message, Message});\r
35         [] ->\r
36             io:format(standard_error, "Room ~s@~s unavailable~n", [Room, Host]),\r
37             halt(1)\r
38     end.\r
39 \r
40 % vim:set filetype=erlang tabstop=4 expandtab:\r