From a80378eebdbbf5367498fd67085625507e9b4268 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 2 Nov 2015 14:04:47 +0100 Subject: [PATCH] --- phork0.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 phork0.txt diff --git a/phork0.txt b/phork0.txt new file mode 100644 index 0000000..61f6088 --- /dev/null +++ b/phork0.txt @@ -0,0 +1,40 @@ +#!/usr/bin/env escript +%%! -sname sender@localhost +%% +%% Written by Holger Weiss . +%% + +% +% 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 = + 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: -- 2.30.2