Page 1 of 3

pyNSrecruit 0.2.4 | Auto-Telegramming/Recruitment Tool

PostPosted: Sat Apr 18, 2015 2:57 am
by South Jarvis
pyNSrecruit (that's ‘pines-recruit’) is an open-source cross-platform desktop application to use the NationStates Telegram API to automatically telegram nations. It is designed to be robust, minimising the prevalence of crashes, and powerful, with a wide range of capabilities.

Screenshots
Image
Image

Download
Remember, this software is still in development. If you encounter any bugs, I'd very much like to know about them.
Stable: 0.2.4 (.zip), (.tar.gz)
Source: GitHub

Instructions
See the Quick Start Guide on the pyNSrecruit GitHub page for detailed instructions.

I don't often monitor the forums, so if you have questions or issues, it may be worthwhile telegramming me.

PostPosted: Sat Apr 18, 2015 3:28 am
by Conservative Values
As someone who is looking to build up a conservative region, the ability to filter by government type is really awesome. I may try this out soon! We appreciate the effort, thanks! :hug:

PostPosted: Sat Apr 18, 2015 5:33 pm
by Ainocra
i'll try it out and let you know if I find any bugs, looks like a great idea

PostPosted: Sat Apr 18, 2015 5:55 pm
by Kemintiri of Kemet
"pyNS" sounds really awkward... :oops:

On a more serious note: Good luck! :)

PostPosted: Sat Apr 18, 2015 5:57 pm
by Hobbesistan
I like this.

PostPosted: Sat Apr 18, 2015 8:05 pm
by South Jarvis
Kemintiri of Kemet wrote:"pyNS" sounds really awkward... :oops:

On a more serious note: Good luck! :)

(Aah... This is why you don't get developers to name their products.) I imagine that it's pronounced 'pines' ('py' as in 'Python'). I should clarify that in my post...

PostPosted: Sun Apr 19, 2015 4:33 am
by Ainocra
Jarvis

Ok I tinkered with it. I took a list of nations in my region and tried to send them a message

i used include
by name and then listed the names

this is what I got as output, I do not think it sent anything.
I suspect I am doing something wrong though.

2015-04-19 07:03:04 [ERRR] An error occurred while loading session data. Check the log.
JSONDecodeError('Expecting value: line 1 column 1 (char 0)',)
2015-04-19 07:20:25 [INFO] Starting telegramming.
2015-04-19 07:20:25 [INFO] Started telegramming.
2015-04-19 07:20:25 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:20:25 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:20:55 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:20:55 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:21:25 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:21:25 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:21:55 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:21:55 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:22:25 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:22:25 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:22:55 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:22:55 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:23:25 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:23:25 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:23:55 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:23:55 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:24:25 [INFO] Stopping telegramming. Telegramming will stop when waiting finishes.
2015-04-19 07:24:25 [INFO] Stopped telegramming.
2015-04-19 07:25:01 [INFO] Starting telegramming.
2015-04-19 07:25:01 [INFO] Started telegramming.
2015-04-19 07:25:01 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:25:01 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:25:31 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:25:31 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:26:01 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:26:01 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:26:31 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:26:31 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:27:01 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:27:01 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:27:31 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:27:31 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:28:01 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:28:01 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:28:31 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:28:31 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:29:01 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:29:01 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 07:29:31 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 07:29:31 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.


PostPosted: Sun Apr 19, 2015 5:10 am
by South Jarvis
Ainocra wrote:this is what I got as output, I do not think it sent anything.


It looks like you're trying to save/load from a file. Can you try using a smaller list of recipients and not using File->Save and File->Load? What are the contents of the file you are trying to File->Load?

PostPosted: Sun Apr 19, 2015 6:35 am
by Indian Empire
Could you make this available somewhere else besides GitHub? Like say, an Android app?

PostPosted: Sun Apr 19, 2015 7:21 am
by Enfaru
Indian Empire wrote:Could you make this available somewhere else besides GitHub? Like say, an Android app?


That would be fine if it was in release stage, it isn't. It's in development stage, it's not ready to be released. That's why it's on github and not in an app store.

PostPosted: Sun Apr 19, 2015 12:29 pm
by Ainocra
Jarvis

ok I wrote a new one on the fly entirely from scratch and cut the list down to around 20 nations and this was the output.
the previous list was only around a hundred nations. To be clear I'm not going for nation type but wanting to tg a specific group of individuals
again I used include, by name as the only parameters for the list of recipients.

2015-04-19 15:19:07 [INFO] Starting telegramming.
2015-04-19 15:19:07 [INFO] Started telegramming.
2015-04-19 15:19:07 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:19:07 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:19:37 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:19:37 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:19:50 [INFO] Stopping telegramming. Telegramming will stop when waiting finishes.
2015-04-19 15:20:07 [INFO] Stopped telegramming.
2015-04-19 15:21:07 [INFO] Starting telegramming.
2015-04-19 15:21:07 [INFO] Started telegramming.
2015-04-19 15:21:07 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:21:07 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:21:37 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:21:37 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:22:07 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:22:07 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:22:37 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:22:37 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:23:07 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:23:07 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:23:37 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:23:37 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.
2015-04-19 15:24:07 [WARN] All applicable nations have been telegrammed already. Waiting 30 seconds.
2015-04-19 15:24:07 [WARN] If telegramming a fixed number of recipients, it is safe to stop telegramming now.



PostPosted: Sun Apr 19, 2015 6:10 pm
by South Jarvis
Ainocra wrote:ok I wrote a new one on the fly entirely from scratch and cut the list down to around 20 nations and this was the output.


Are you sure you saved the settings to a campaign (the 'Save' button in the bottom left corner)? Your interface should look like this: http://imgur.com/9ZHqunZ - Note the entry in the list on the left.

If you record your screen while you set up the program and share the video online, it would help me troubleshoot your issue.

(EDIT: Whoops, something called 'Secret Key' should probably be censored from a screenshot...)

PostPosted: Sun Apr 19, 2015 7:35 pm
by Ainocra
ok that's what i was doing wrong, i think i got it rolling

seems to be working

v0.2.1

PostPosted: Fri Apr 24, 2015 1:22 am
by South Jarvis
Updated to version 0.2.1:

  • Added the 'Mother Knows Best' category to the Exclude By Category filter.

https://github.com/RunasSudo/pyNSrecrui ... /tag/0.2.1

PostPosted: Wed May 06, 2015 1:25 am
by The Confederate State of Missouri
Being able to copy and paste the telegram info: API key, secret key, telgram ID would be cool.

PostPosted: Wed May 06, 2015 7:06 pm
by Anaaxes
The Confederate State of Missouri wrote:Being able to copy and paste the telegram info: API key, secret key, telgram ID would be cool.


While you can't use left click to paste things into the input boxes, CTRL+V seemed to work (Windows).




Nice work South Jarvis; definitely the best recruitment tool I've seen out there. :)

PostPosted: Wed May 06, 2015 11:56 pm
by The Confederate State of Missouri
Ah, never think of actually using the keyboard shortcuts. :oops: After having used Auralia's nationstates autotelegram to do this for some time now I can assure you that this is much less resource intensive on your computer. Congratulations to the creator for a fine job.

PostPosted: Fri May 22, 2015 5:18 pm
by Ainocra
Just wanted to stop in and say thing thing work great, many thanks to the author.

I have noticed one thing though, if you TG people on a list, It will make a loop.

So tonight I made a list and sent out about 200 or so tg's. I was at the start of the list. It sent it to the entire list then looped around and sent it to me again.

is there some way to make it stop sending once it has completed the list once?

PostPosted: Sat May 23, 2015 10:58 am
by Conservative Values
I would also like to really thank you for making this, by being able to exclude liberal government categories my API recruitment is pulling nearly 3% recruitment rate, which is way better than just hitting everyone!

One thing that I've noticed that surprised me is that focusing on nations by action of "refounding" includes both foundings and refoundings. I was looking to focus on those being refounded for a bit so as not to compete with my stamp campaign I was running to the "new" tag. I would think refounding would mean just those that are refounded, and if I wanted both then I would add both of them.

Either way, awesome tool is awesome!

PostPosted: Wed May 27, 2015 1:01 am
by South Jarvis
Thanks for all your support, everyone! It really means a lot to know that one's work is seeing active use.

Ainocra wrote:So tonight I made a list and sent out about 200 or so tg's. I was at the start of the list. It sent it to the entire list then looped around and sent it to me again.


Unfortunately, pyNSrecruit only keeps track of the last 100 nations telegrammed when attempting to prevent loops. I intend to make this configurable in the future, and make the program smarter to avoid this (though I have a lot on my plate at the moment, and so it might take a while to get done).

In the meanwhile, if you think your computer can handle it (it should be okay?) you can edit line 386 of main.py:
Code: Select all
telegramHistory = collections.deque(maxlen=100) #TODO: Make this configurable.

Change the '100' to some number greater than the number of nations you're trying to telegram.

Conservative Values wrote:One thing that I've noticed that surprised me is that focusing on nations by action of "refounding" includes both foundings and refoundings.

That seems strange. I don't think it should do that. I've opened an issue on the issue tracker.

PostPosted: Fri Jun 05, 2015 8:37 pm
by Misley
If a nation ceases to exist between being added to the pool of recruitable nations and attempting to send the telegram, the recruitment thread breaks when checking the nation against excluded categories, as making an API call for a nonexistent nation throws a 404 error.

The problem is with
Code: Select all
resp = urllib.request.urlopen(req)
on line 289, which breaks upon a 404 error and doesn't allow the code to process to your attempt to handle non-200 responses with the else statement a few lines later

edit: this change fixed it on my end, but as you can tell it's intended to be a temp-fix to keep it running rather than an actual meaningful fix:

Code: Select all
def matches(self, nation):
      req = urllib.request.Request("https://www.nationstates.net/cgi-bin/api.cgi?nation={0}&q=category".format(nation))
      req.add_header("User-Agent", "pyNSrecruit/{0} (South Jarvis)".format(VERSION))
      try:
         resp = urllib.request.urlopen(req)
         if resp.status == 200:
            data = resp.read().decode("utf-8")
            nationCategory = re.search(r"<CATEGORY>(.*)</CATEGORY>", data).group(1)
            log(DEBG, "Got category {0}.".format(nationCategory))
            for matchCategory in self.categories:
               if nationCategory == matchCategory:
                  return (True if self.inverted == 0 else False)
            return (False if self.inverted == 0 else True)
         else:
            #log(ERRR, "Unable to load data for {1}. Got response code {0}.".format(resp.status, nation))
            return True #Be safe!
      except urllib.error.HTTPError as e:
         log(ERRR, "Unable to load category data. Got some kinda fuckin error")
         return True

this replaces lines 286 through 301 in main.py. I commented out the log in the "else" and didn't include any additional info in the "except" log because it was throwing errors that I didn't care enough to fix.

PostPosted: Fri Jun 05, 2015 10:23 pm
by Sad-States
Nice to see new coders arising in the community :)

PostPosted: Sat Jun 06, 2015 12:08 am
by South Jarvis
Misley wrote:If a nation ceases to exist between being added to the pool of recruitable nations and attempting to send the telegram, the recruitment thread breaks when checking the nation against excluded categories, as making an API call for a nonexistent nation throws a 404 error.


Thanks for reporting this! I've created an issue on the GitHub issue tracker.

EDIT: I've released 0.2.2, which includes a try-catch block around the exclusion filter code, per your suggestion. I've also opened an issue to refactor all of the HTTP code to better deal with these circumstances.

PostPosted: Sun Jun 07, 2015 7:11 am
by WikiPlay
Sad-States wrote:Nice to see new coders arising in the community :)

I fully agree with the positive side of the internet. :)

PostPosted: Mon Jun 15, 2015 12:21 pm
by Letoilenoir
http://www.nationstates.net/cgi-bin/api ... ilter=move

Could this be added as an alternative filter?

Reasoning being if a nation is already prepared to move they might be tempted to a different region than they originally aimed for