wesnoth/utils/campaign_delete.pl
Bruno Wolff III 9141130ed9 I added a passphrase changing function on the server
(but not the normal client) so that campaigns can have their
passphrases reset by admins without shutting the server down. I also
add two perl scripts for changing passphrases and for deleting
campaigns.
2005-11-19 18:14:41 +00:00

46 lines
785 B
Perl
Executable File

#!/usr/bin/perl
use wml;
use wml_net;
use strict;
my ($host, $port) = ("campaigns.wesnoth.org", 15002);
$| = 1;
print "Campaign name to be deleted: ";
my $name = <STDIN>;
chomp $name;
print "Passphrase: ";
my $old = <STDIN>;
chomp $old;
my $socket = &wml_net::connect($host,$port);
if (!defined($socket)) {
print "Error connecting to the campaign server\n";
exit;
}
&wml_net::write_packet($socket,&wml::read_text( << "EOF" ));
[delete]
name=\"$name\"
passphrase=\"$old\"
[/delete]
EOF
my $response = &wml_net::read_packet($socket);
if (!defined($response)) {
print "Error accessing the campaign server.\n";
exit;
}
if (my $error = &wml::has_child($response, 'error')) {
printf "Error: %s\n", $error->{'attr'}->{'message'};
exit;
}
print "Campaign deleted.\n";