From d2754512c34a19dad7e489b97fd80bf0bd634089 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 8 Aug 2010 22:46:49 +0200 Subject: add some crap Signed-off-by: Florian Pritz --- jabberwall.pl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 jabberwall.pl (limited to 'jabberwall.pl') 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), " \n"; + exit 1; +} + +open FH, "<", $ARGV[0] or die "$ARGV[0]: $!"; +my @recipients = ; +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 () { + $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(); -- cgit v1.2.3-24-g4f1b