diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-08-08 22:46:49 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-08-08 22:46:49 +0200 |
commit | d2754512c34a19dad7e489b97fd80bf0bd634089 (patch) | |
tree | 263e282b4c012a09ca95c51d5513eaa5982bb355 /jabberwall.pl | |
parent | 0170ef29ce9748022bc3437e3b981dcdc60cfd9e (diff) | |
download | bin-d2754512c34a19dad7e489b97fd80bf0bd634089.tar.gz bin-d2754512c34a19dad7e489b97fd80bf0bd634089.tar.xz |
add some crap
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'jabberwall.pl')
-rwxr-xr-x | jabberwall.pl | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/jabberwall.pl b/jabberwall.pl new file mode 100755 index 0000000..c8c4897 --- /dev/null +++ b/jabberwall.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Config::Simple; +use Net::Jabber qw(Client); +use File::Basename; +use Data::Dumper; + +# config file syntax: "option value" +# options are: server, port, username, password, ressource +# location: ~/.jabberwallrc + +if(@ARGV != 1) { + print "usage: ", basename($0), " <userlist>\n"; + exit 1; +} + +open FH, "<", $ARGV[0] or die "$ARGV[0]: $!"; +my @recipients = <FH>; +close FH; + +my %config; +Config::Simple->import_from("$ENV{HOME}/.jabberwallrc", \%config); + +my $clnt = new Net::Jabber::Client; + +my $status = $clnt->Connect(hostname=>$config{server}, port=>$config{port}); + +if (!defined($status)) { + die "Jabber connect error ($!)\n"; +} + +my @result = $clnt->AuthSend(username=>$config{username}, + password=>$config{password}, + resource=>$config{resource}); + +if ($result[0] ne "ok") { + die "Jabber auth error: @result\n"; +} + +my $body = ''; +while (<STDIN>) { + $body .= $_; +} +chomp($body); + +for my $to (@recipients) { + chomp $to; + next if ($to eq ""); + + $clnt->MessageSend(to=>$to, + subject=>"", + body=>$body, + type=>"chat", + priority=>0); +} + +$clnt->Disconnect(); |