NATION

PASSWORD

pyNSrecruit 0.2.4 | Auto-Telegramming/Recruitment Tool

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

pyNSrecruit 0.2.4 | Auto-Telegramming/Recruitment Tool

Postby South Jarvis » Sat Apr 18, 2015 2:57 am

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.
Last edited by South Jarvis on Thu Mar 16, 2017 10:32 pm, edited 9 times in total.

User avatar
Conservative Values
Envoy
 
Posts: 331
Founded: Mar 29, 2013
Right-wing Utopia

Postby Conservative Values » Sat Apr 18, 2015 3:28 am

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:

User avatar
Ainocra
Ambassador
 
Posts: 1430
Founded: Sep 20, 2009
Father Knows Best State

Postby Ainocra » Sat Apr 18, 2015 5:33 pm

i'll try it out and let you know if I find any bugs, looks like a great idea
Alcon Enta
Supreme Marshal of Ainocra

"From far, from eve and morning and yon twelve-winded sky, the stuff of life to knit blew hither: here am I. ...Now--for a breath I tarry nor yet disperse apart--take my hand quick and tell me, what have you in your heart." --Roger Zelazny

User avatar
Kemintiri of Kemet
Envoy
 
Posts: 241
Founded: Jan 24, 2015
Ex-Nation

Postby Kemintiri of Kemet » Sat Apr 18, 2015 5:55 pm

"pyNS" sounds really awkward... :oops:

On a more serious note: Good luck! :)
Yo Mama|Elegy for Easter|Black of Knight|On Tagger's Fields|Raid Regions|A Thousand Days of Mourning In Honour Of My Fallen Loved One|Love-lies-bleeding|It Is Heartbreak
Կէմինտիրի Թեոդորա Շնեժ Մոնտրէսոր
Kemintiri T'yeodora Snez Montresor

100 Invader 63 Defender
Niece of Tim Stark, Escade and Solorni
Daughter of Severisen and Xoriet
Niece-by-marriage of Dalimbar
Granddaughter of Minineenee
Descendant of Astarial
Half-sister of Rirersyl
Sister of Ramaeus
Cousin of Knot

User avatar
Hobbesistan
Minister
 
Posts: 2448
Founded: Jul 01, 2013
Ex-Nation

Postby Hobbesistan » Sat Apr 18, 2015 5:57 pm

I like this.
Hobbes
ra, ra rasputin

(Ret.) Maintainer of the Nationstates FAQ and Deletiger (Ret.) of The East Pacific
russia's greatest

Hobbes is always winning, like Charlie Sheen. - Jurisdictions
love machine

Stop right there (hobbes), your rational thought and intellect will destroy the internet. - Sovreignry
it was a shame how

Giraffes think Hobbes regret a lot. A lot of giraffes do. - Rachel
he carried on.

User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

Postby South Jarvis » Sat Apr 18, 2015 8:05 pm

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...
Last edited by South Jarvis on Sat Apr 18, 2015 8:20 pm, edited 2 times in total.

User avatar
Ainocra
Ambassador
 
Posts: 1430
Founded: Sep 20, 2009
Father Knows Best State

Postby Ainocra » Sun Apr 19, 2015 4:33 am

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.

Alcon Enta
Supreme Marshal of Ainocra

"From far, from eve and morning and yon twelve-winded sky, the stuff of life to knit blew hither: here am I. ...Now--for a breath I tarry nor yet disperse apart--take my hand quick and tell me, what have you in your heart." --Roger Zelazny

User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

Postby South Jarvis » Sun Apr 19, 2015 5:10 am

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?

User avatar
Indian Empire
Minister
 
Posts: 2087
Founded: Mar 29, 2013
Democratic Socialists

Postby Indian Empire » Sun Apr 19, 2015 6:35 am

Could you make this available somewhere else besides GitHub? Like say, an Android app?
Internet Explorer, IE, "Preacher of Defender Ideals"

User avatar
Enfaru
Minister
 
Posts: 2921
Founded: Apr 20, 2012
Ex-Nation

Postby Enfaru » Sun Apr 19, 2015 7:21 am

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.
Sovereign Charter Quick Links
Factbook · Role-plays · RMB · Map (Origin | Quantum) · Chat · Members: 73
Myraxia: One does not learn to GM; One throws oneself in and prays they don't fuck up too badly.
Game Master
Founder of the Sovereign Charter,
4th President and,
Tutor of the College of Theatrics

User avatar
Ainocra
Ambassador
 
Posts: 1430
Founded: Sep 20, 2009
Father Knows Best State

Postby Ainocra » Sun Apr 19, 2015 12:29 pm

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.


Alcon Enta
Supreme Marshal of Ainocra

"From far, from eve and morning and yon twelve-winded sky, the stuff of life to knit blew hither: here am I. ...Now--for a breath I tarry nor yet disperse apart--take my hand quick and tell me, what have you in your heart." --Roger Zelazny

User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

Postby South Jarvis » Sun Apr 19, 2015 6:10 pm

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...)
Last edited by South Jarvis on Sun Apr 19, 2015 7:29 pm, edited 3 times in total.

User avatar
Ainocra
Ambassador
 
Posts: 1430
Founded: Sep 20, 2009
Father Knows Best State

Postby Ainocra » Sun Apr 19, 2015 7:35 pm

ok that's what i was doing wrong, i think i got it rolling

seems to be working
Last edited by Ainocra on Sun Apr 19, 2015 8:25 pm, edited 1 time in total.
Alcon Enta
Supreme Marshal of Ainocra

"From far, from eve and morning and yon twelve-winded sky, the stuff of life to knit blew hither: here am I. ...Now--for a breath I tarry nor yet disperse apart--take my hand quick and tell me, what have you in your heart." --Roger Zelazny

User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

v0.2.1

Postby South Jarvis » Fri Apr 24, 2015 1:22 am

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

User avatar
The Confederate State of Missouri
Lobbyist
 
Posts: 13
Founded: Mar 13, 2013
Ex-Nation

Postby The Confederate State of Missouri » Wed May 06, 2015 1:25 am

Being able to copy and paste the telegram info: API key, secret key, telgram ID would be cool.

User avatar
Anaaxes
Civil Servant
 
Posts: 7
Founded: Nov 28, 2012
Civil Rights Lovefest

Postby Anaaxes » Wed May 06, 2015 7:06 pm

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. :)
Speaker of the Union and
Former Delegate of the Social Liberal Union

User avatar
The Confederate State of Missouri
Lobbyist
 
Posts: 13
Founded: Mar 13, 2013
Ex-Nation

Postby The Confederate State of Missouri » Wed May 06, 2015 11:56 pm

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.

User avatar
Ainocra
Ambassador
 
Posts: 1430
Founded: Sep 20, 2009
Father Knows Best State

Postby Ainocra » Fri May 22, 2015 5:18 pm

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?
Last edited by Ainocra on Fri May 22, 2015 6:04 pm, edited 1 time in total.
Alcon Enta
Supreme Marshal of Ainocra

"From far, from eve and morning and yon twelve-winded sky, the stuff of life to knit blew hither: here am I. ...Now--for a breath I tarry nor yet disperse apart--take my hand quick and tell me, what have you in your heart." --Roger Zelazny

User avatar
Conservative Values
Envoy
 
Posts: 331
Founded: Mar 29, 2013
Right-wing Utopia

Postby Conservative Values » Sat May 23, 2015 10:58 am

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!

User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

Postby South Jarvis » Wed May 27, 2015 1:01 am

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.
Last edited by South Jarvis on Wed May 27, 2015 4:11 am, edited 1 time in total.

User avatar
Misley
Diplomat
 
Posts: 609
Founded: Jan 05, 2009
Ex-Nation

Postby Misley » Fri Jun 05, 2015 8:37 pm

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.
Last edited by Misley on Fri Jun 05, 2015 9:07 pm, edited 1 time in total.
EGO·VERO·CUSTOSFRATRIS·MEI·SUM
Socialist People's Provinces of Misley

   
Editor of the Red & Black
Fleet Admiral of The Red Fleet
Custodian of The Internationale

User avatar
Sad-States
Envoy
 
Posts: 207
Founded: Oct 04, 2013
Ex-Nation

Postby Sad-States » Fri Jun 05, 2015 10:23 pm

Nice to see new coders arising in the community :)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Former Magister to The East Pacific | Former Officer to the EPSA | Former Officer of HR to The Rejected Realms | -
- Former Evocatus to Legio Pacifica -
Proud Warden to the Order of The Grey Wardens
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

User avatar
South Jarvis
Bureaucrat
 
Posts: 53
Founded: Oct 15, 2013
Ex-Nation

Postby South Jarvis » Sat Jun 06, 2015 12:08 am

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.
Last edited by South Jarvis on Sat Jun 06, 2015 12:23 am, edited 3 times in total.

User avatar
WikiPlay
Attaché
 
Posts: 76
Founded: May 09, 2015
Ex-Nation

Postby WikiPlay » Sun Jun 07, 2015 7:11 am

Sad-States wrote:Nice to see new coders arising in the community :)

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

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Mon Jun 15, 2015 12:21 pm

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
KEEP THE BLOOD CAVE FREE

Next

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Catsarecute, Escapania, The Red Tabby, The Southern Dependencies, Wolfhawk

Advertisement

Remove ads