Skip to content

levashovm/nu_python_scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nu_python_scripts

Python scripts for interacting with planets.nu

Requires python to be installed on the computer: https://www.python.org/downloads/

pull_messages.py script

usage: pull_messages.py [-h] [--format {csv,mbox}] [--username USERNAME] [--password PASSWORD] GAMEID

GAMEID is the 6-digit numeric game number that can be found in game history or in the URL of the game.

Pulling messages in CSV (comma separated values) format

CSV format is the default. For finished games, you only need to give the GAMEID value to the script. For games still in progress, your planets.nu USERNAME and PASSWORD are also required.

python pull_messages.py --username USERNAME --password PASSWORD GAMEID

When using the CSV format, the script will:

a) check that the game exists. If the game is still in progress, it will login

b) create a game_data/tmp local folder and download the game_data into the folder as a zip file

c) unzip the file into game_data/tmp

d) extract all of the messages and export them into messages_[GAMEID].csv file. The csv file can be opened using any text editor or Excel/Excel-like program

e) remove the files from game_data/tmp to save disk space

i) the zip file will remain in game_data folder. It can be deleted

Pulling messages in mbox format

When pulling messages for a game in mbox format, it's then possible to import the mbox file into an e-mail reader to read the in-game messages. When using mbox format, you need to give the following parameters to the script:

python pull_messages.py --format mbox --username USERNAME --password PASSWORD GAMEID

The script will:

a) log in to planets.nu with the given username and password

b) fetch all messages for all races in the game

c) extract all the messages in mbox format to messages_[GAMEID].mbox file. The file can be imported to an e-mail program such as Thunderbird or Outlook. (Thunderbird requires a plugin, such as "ImportExportTools NG" to import mbox files).

NOTE: It's possible that not all messages are fetched when using the mbox format. For example, for Capricorn war, only about the most recent 150 turns worth of messages was received when testing this script.

Detailed Examples

Preparation to run nu_python_scripts on Windows

  1. Install Python 3 from https://www.python.org/downloads/windows/ NOTE: During installation, you need to check Add Python to PATH. Otherwise, you may have to specify the full path to python.exe when running it from the command line. It is also recommended to check the option to install the pip utility, which will help you install missing python modules.
  2. Download the nu_python_scripts code as ZIP and unzip in a local folder (C:\Users\XXX\nu_python_scripts-main for this example)
  3. Launch Windows Command Prompt
  4. Change directory to where you unzipped the code
cd C:\Users\XXX\nu_python_scripts-main
  1. Try running
python pull_messages.py
  1. If there is an Error message No module named ... you can install that module using the pip utility. In this example, the module requests was missing and it was installed with
pip install requests

Reading message history from the Libra War using Google Docs on Windows

  1. Run the script with the GAME# of the Libra War
python pull_messages.py 267580

Note: A few of the turns failed to parse for an unknown reason

  1. Upload C:\Users\XXX\nu_python_scripts-main\messages_267580.csv into Google Docs and change the column width to something more reasonable
  2. Enjoy all of the in-game communications from the Libra War in a more accessible format

Reading message history from the Libra War using Thunderbird on Windows

  1. Run the script with the GAMEID of the Libra War with additional arguments, including your planets.nu USERNAME and PASSWORD:
python pull_messages.py 267580 --format mbox --username USERNAME --password PASSWORD
  1. Install Thunderbird Email client and launch it
  2. Unfortunately, there is no way to import messages into Thunderbird without setting up an account. You can either set it up with a real account or a bogus account. To use a bogus account, fill out Your name and Email address fields, click Configure Manually, Advanced Config and then disable Check for new messages at startup and Check for new messages every... tickboxes
  3. In Thunderbird Add-ons menu search for ImportExportTools NG and click Add to Thunderbird
  4. On the left-hand side, right click on Local Folders and select ImportExportTools NG->Import mbox file->Import directly one or more mbox files->OK
  5. Choose the file generated by the script: C:\Users\XXX\nu_python_scripts-main\messages_267580.mbox
  6. You should now have a folder with thousands of messages from the game. They can be grouped by conversations, sorted and searched

About

Python scripts for interacting with planets.nu

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages