Hello
I'm trying to build an IRC Bot which tells me in a private channel every commit-message which I want to know about. But I have trouble to get per
#!/bin/bash
REPOS="$1"
REV="$2"
# call bot with arguments reposname, revison and commit message in one string
/usr/bin/perl /home/user/repo/svn_irc_bot.pl "$REPOS" "$REV"
# all checks passed, so allow the commit
exit 0
Then, the invoked Perl-Skript:
#!/usr/bin/perl -w
# see http://www.javalinux.it/wordpress/2009/10/15/writing-an-irc-bot-for-svn-commit-notification/
# see http://oreilly.com/pub/h/1964
use strict;
# We will use a raw socket to connect to the IRC server.
use IO::Socket;
my $repos = $ARGV[0];
my $rev = $ARGV[1];
my $commit = `/usr/bin/svnlook log $repos`;
my $user = `whoami`;
# The server to connect to and our details.
my $server = "irc.server.com";
my $nick = "bot2";
my $login = "bot2";
# The channel which the bot will join.
# my $channel = "#channel";
# Connect to the IRC server.
my $sock = new IO::Socket::INET(PeerAddr => $server,
PeerPort => 6667,
Proto => 'tcp') or
die "Can't connect\n";
# Log on to the server.
print $sock "NICK $nick\r\n";
print $sock "USER $login 8 * :Perl IRC Hacks Robot\r\n";
# Read lines from the server until it tells us we have connected.
while (my $input = <$sock>) {
# Check the numerical responses from the server.
if ($input =~ /004/) {
# We are now logged in.
print $sock "PRIVMSG mynick : $user: $repos r$rev -- $commit\n";
last;
}
elsif ($input =~ /433/) {
die "Nickname is already in use.";
}
}
sleep(5);
print $sock "QUIT bye... \n";
sleep(5);
close($sock);
So, my Bot does connect, and can talk to me...
If I start the shell Script manually, only one word (the string inside $user, not even the following colon) is sent.
If the script is invoked by SVN trough a commit, is seems like the $user and $commit strings are empty, $user and $repos are transmitted...
I guess that something is wrong with my usage of whoami and svnlook... But I can't figure it out. Maybe someone can give me a hint?