Jump to content

User:AnomieBOT/source/send-command.pl

From Wikipedia, the free encyclopedia
#!/usr/bin/perl -w

use strict;

use Cwd;
use File::Basename;
use lib File::Basename::dirname( Cwd::realpath( __FILE__ ) );
use AnomieBOT::API;

my $botnum = shift // die "USAGE: $0 botnum cmd";
my $cmd = shift // die "USAGE: $0 botnum cmd";

$cmd = undef if $cmd eq '';

my ($api, $cmdfile);
if ( $botnum eq 'updater' ) {
    $api = AnomieBOT::API->new("conf.ini", 1, { db => 0 });
    $cmdfile = 'cache:command:AnomieBOT-updater';
} else {
    $api = AnomieBOT::API->new("conf.ini", $botnum, { db => 0 });
    $cmdfile = $api->{'commandfile'};
}
warn "Failed to write $cmdfile: $!\n" unless $api->send_command( $cmdfile, $cmd );