by Max Barry

Latest Forum Topics

Advertisement

67

DispatchMetaReference

by Nephmir. . 2,172 reads.

Maintaining A Sleeper Network (Login Script)

Step 1: Download Script Program
You'll need to download LinkStrawberry Perl to use and launch the script.

Step 2: Open Notepad or Notepad++
Open a new notepad and paste the following script into it (script written by Ballotonia, telegram checker (included) written by The Blaatschapen, all found in this thread):

#!/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://century.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";
}
}

You'll need to go back and edit in your nation names and passwords as indicated in the script before the dashed line. You can easily add as many nations as you like, each on their own line in the required format. Make sure all nations and passwords are typed correctly, and are inside the quotations!

Step 3: Save the Script
Save the file under "Documents" as "NameOfFile.pl". Make sure you include the .pl in whatever name you choose for the script. Copy the direct path to the saved script (something like "C://Users/@@NAME@@/Documents/NameOfFile.pl").

Step 4: Open the Command Prompt
Search for "Strawberry Perl (Command Line)" on your computer, and open it.

Step 5: Launch the Script
Type: cd..
Hit Enter.
Type: cd..
Hit Enter.
Type: cd
Hit Enter.
Type: perl PASTE_FILE_PATH_HERE.pl
Hit Enter.

Your script will now launch after a few second's delay, followed by each nation appearing on a new line every time a log in is successful. It will also indicate if that nation has any new telegrams.

Enjoy!

Tip: Keeping your sleepers in your dossier is a good way to stay organized and keep track of your nations, and to easily log into them manually without a script. Also, keep in mind that nations stop gaining influence if they haven't been logged into in more than seven (7) days, and cease to exist if inactive for twenty-eight (28) days, or sixty (60) days in vacation mode.


Please upvote this dispatch if you found it helpful!

Nephmir

Edited:

RawReport