#!/usr/bin/env perl
# Copyright (C) 2004 by İsmail Dönmez
# Licensed under GPL v2 or later at your option

$PORT= shift;
$SERVER= shift;
$TARGET= shift;

my $i;

if( $ARGV[0] eq "yes" ){
    exec 'dcop', $PORT, 'Konversation', 'error', 'Requested command is not executed!';
}

$ARG_MESSAGE = `@ARGV`;

foreach $entry (split(/\n/, $ARG_MESSAGE)) {
    chomp $entry;
    $i=1;
    $entry =~ s/^\//\/\//;
    system 'dcop', $PORT, 'Konversation', 'say', $SERVER, $TARGET, $entry;
}

unless($i) {
    exec 'dcop', $PORT, 'Konversation', 'error', 'Command @ARGV doesn\'t exist!';
}
