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 | #!/usr/bin/env escript %%! -sname sender@localhost %% %% Written by Holger Weiss <holger@zedat.fu-berlin.de>. %% % % If the node name of your server is not 'ejabberd@localhost' (see the % "ejabberdctl status" output), you must change the @localhost part of % the node names above and below. % % Apart from that, you must set Room and Host to the desired values % below. % main(Args) -> Room = <<"test">>, Host = <<"conference.example.com">>, Node = 'ejabberd@localhost', Usage = "send-muc-message <message> ...", Message = case string:join(Args, " ") of [] -> io:format(standard_error, "Usage: ~s~n", [Usage]), halt(2); Joined -> list_to_binary(Joined) end, case rpc:call(Node, mnesia, dirty_read, [muc_online_room, {Room, Host}]) of [R] -> Pid = element(3, R), gen_fsm:send_all_state_event(Pid, {service_message, Message}); [] -> io:format(standard_error, "Room ~s@~s unavailable~n", [Room, Host]), halt(1) end. % vim:set filetype=erlang tabstop=4 expandtab: |