NATION

PASSWORD

Scripting Clarification

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
Nephmir
Ambassador
 
Posts: 1760
Founded: Dec 30, 2013
Ex-Nation

Scripting Clarification

Postby Nephmir » Thu Dec 18, 2014 9:00 am

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";
  }
}
SC Resolutions
SC#165 | SC#173
_
_
The 300 Endorsements of Nephmir
"100 by land, 100 by air, 100 by sea."
Mercenary of The Sable Order
Commander in Project Soul

User avatar
Sichuan Pepper
Diplomat
 
Posts: 974
Founded: Aug 12, 2011
Ex-Nation

Postby Sichuan Pepper » Thu Dec 18, 2014 11:35 am

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.
Wordy, EX-TITO Field Commander.
Now just ornamental.

Mallorea and Riva wrote:Yeah but no one here can read. Literacy is a tool used by fendas, like IRC or morals.

User avatar
[violet]
Executive Director
 
Posts: 16207
Founded: Antiquity

Postby [violet] » Thu Dec 18, 2014 11:48 am

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.

User avatar
Ballotonia
Senior Admin
 
Posts: 5494
Founded: Antiquity
Democratic Socialists

Postby Ballotonia » Thu Dec 18, 2014 12:01 pm

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
Last edited by Ballotonia on Thu Dec 18, 2014 12:02 pm, edited 1 time in total.
"Een volk dat voor tirannen zwicht zal meer dan lijf en goed verliezen, dan dooft het licht…" -- H.M. van Randwijk

User avatar
The Blaatschapen
Technical Moderator
 
Posts: 63227
Founded: Antiquity
Anarchy

Postby The Blaatschapen » Thu Dec 18, 2014 12:02 pm

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
The Blaatschapen should resign


Return to Technical

Who is online

Users browsing this forum: Ankuran

Advertisement

Remove ads