Secondly, I am aware that there is an auto login script available currently (below), but is there one that can answer issues? If it is legal, of course. If not, would there be a way to alter the script below to answer issues after logging in at the designated time (so that I can run two scripts, one for Minor Update and another for Major)?
- Code: Select all
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
# Enter your MAIN Nation name here:
my $username = "YOURMAINNATIONNAME";
# Enter names and passwords of your nations here:
my @nations = (
["nation1", "password1"],
["nation2", "password2"],
["nation3", "password3"],
);
# ---------------------------------------------------------------------------------------------
# --- Nothing to edit beyond this point ---
my $delayTime = 6; # pause between fetches
my $mech = WWW::Mechanize->new ();
$mech->agent ("Nation:$username ");
foreach my $loginItem (@nations)
{
my $nation = lc($loginItem->[0]);
$nation =~ s/ /_/g;
my $password = $loginItem->[1];
print "\nLOGIN: $nation";
my %envelop = ( nation => $nation, password => $password, logging_in => 1);
while (!defined eval {$mech->post ("http://www.nationstates.net", \%envelop)})
{
print "Trying again...\n";
sleep ($delayTime);
}
sleep ($delayTime);
my $pageContent = $mech->content ();
utf8::decode ($pageContent);
if (-1 == rindex ($pageContent, "a href=\"nation=$nation\" class=\"STANDOUT\""))
{
print "LOGIN FAILED! Halting run...\n";
last; # jump out of foreach loop
}
if (-1 != rindex ($pageContent, "You have <a href=\"page=telegrams\">"))
{
print " has telegrams";
}
}