Page 1 of 1

Scripting Clarification

PostPosted: Thu Dec 18, 2014 9:00 am
by Nephmir
Would a script to auto log in and auto answer issues with nations be legal? For example, I want a set of nations to answer issues at the Minor Update and another to answer issues at the Major without the need to log into them all.

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";
  }
}

PostPosted: Thu Dec 18, 2014 11:35 am
by Sichuan Pepper
I believe Ballo used to have a script that could do that. I am under the impression it is legal however always best to check. There were tweaks made to influence gain dependant on nation activity and it would make sense if script rules were updated at the same time but I highly doubt they were.

PostPosted: Thu Dec 18, 2014 11:48 am
by [violet]
Nephmir wrote:Would a script to auto log in and auto answer issues with nations be legal?

Yes, as per the Script Rules. Scripts are prohibited from performing unattended actions that change things other than your own nation. It is fine for a script to do things that only change your own nation, providing it stays within the Rate Limits.

Nephmir wrote:Secondly, I am aware that there is an auto login script available currently (below), but is there one that can answer issues?

There are some, for sure. I'm not sure off the top of my head which ones the authors have made public, though.

PostPosted: Thu Dec 18, 2014 12:01 pm
by Ballotonia
An auto-login script is legal, as is one which answers issues.

The auto-login code above was written by me, though it looks like someone else added the telegram check clause.

There's a much larger version of that script which does indeed answers issues. At least, answers them in the way I liked to have them answered years ago when I ran that script on all the puppets I had back then. The mechanism involved editing tables of data which ended up determining which issues were answered and which choices were made. This would vary per nation. Imagine 200+ nations having unique handling for (at the time) 320 issues. The script also notices embassy requests, incoming telegrams for all nations, and clears the "(1)" marker for new News items. It's been a while since I ran it, so would probably require an update, and most importantly it would need a manual to describe how the tables work that determine which dilemma options are chosen for which nation. Most importantly, I'm not willing to spend the time to provide technical support for that script, so prefer someone else to write/provide their own.

[edit: ninja'd by [Violet]!)

Ballotonia

PostPosted: Thu Dec 18, 2014 12:02 pm
by The Blaatschapen
Ballotonia wrote:An auto-login script is legal, as is one which answers issues.

The auto-login code above was written by me, though it looks like someone else added the telegram check clause.




That would be me: viewtopic.php?p=12850010#p12850010