NATION

PASSWORD

I would like to make an RMB bot

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.

Advertisement

Remove ads

User avatar
[violet]
Site Admin
 
Posts: 15713
Founded: Antiquity

Postby [violet] » Sat Aug 28, 2021 11:28 pm

Doge Land wrote:I always get this error during the execute phase:
Code: Select all
<NATION id="doge_land">
<ERROR>Invalid token in execute mode. Please try again.</ERROR>
</NATION>


I don't know why. I've made sure I've copied and pasted the right token into the token field but still, nothing is working and I keep getting this error.

This can happen if you do something between the "prepare" and "execute" requests that invalidates your current session. I sometimes get it if I'm also logged in to the website via my browser, because I have autologin enabled and it renews my session in the background.

User avatar
All Wild Things
Chargé d'Affaires
 
Posts: 402
Founded: Apr 24, 2017
Inoffensive Centrist Democracy

Postby All Wild Things » Sun Aug 29, 2021 3:19 am

[violet] wrote:As a trial, I've added a Nation Private Command API for making RMB posts.

It's currently undocumented, but follow the same process as for lodging a dispatch:

https://www.nationstates.net/pages/api. ... tecommands

You'll need to send "c=rmbpost", plus these parameters: nation, region, text, mode

E.g.
Code: Select all
curl -H "X-Password: hunter2" -A "UserAgent Example" "https://www.nationstates.net/cgi-bin/api.cgi" --data "nation=testlandia&region=testregionia&c=rmbpost&text=Hello%20there.&mode=prepare"

curl -H "X-Pin: 1234567890" -A "UserAgent Example" "https://www.nationstates.net/cgi-bin/api.cgi" --data "nation=testlandia&region=testregionia&c=rmbpost&text=Hello%20there.&mode=execute&token=1234567890abcdefg"


This will automatically add a signature that says "This is an automated message," and apply some stricter flood control.

Can you please see if you can get this working? I would like all bots to operate via the API.

This is proving popular so far!
It's more a moderation question than a technical one, but -
Is it acceptable to use this to automatically post an "Embassy update" on all my embassy RMBs (assuming their ROs consented)?
Thanks!
Browse The NewsStand
Watch the Wild Life

User avatar
Sedgistan
Senior Issues Moderator
 
Posts: 32089
Founded: Oct 20, 2006
Anarchy

Postby Sedgistan » Sun Aug 29, 2021 4:16 am

All Wild Things wrote:It's more a moderation question than a technical one, but -
Is it acceptable to use this to automatically post an "Embassy update" on all my embassy RMBs (assuming their ROs consented)?
Thanks!

When new Moderation issues come up, unless the situation is serious/urgent, we tend to take a "wait and see if a problem develops" approach. So for now, you can take it that there are no particular rules on this question, besides the regular rules in the OSRS. So unless your embassy updates are spam / flaming/ trolling etc. then you should be fine to post them. We're not going to (for now) assume they are automatically spam.

User avatar
Doge Land
Envoy
 
Posts: 309
Founded: Feb 15, 2019
Moralistic Democracy

Postby Doge Land » Sun Aug 29, 2021 4:47 am

[violet] wrote:
Doge Land wrote:I always get this error during the execute phase:
Code: Select all
<NATION id="doge_land">
<ERROR>Invalid token in execute mode. Please try again.</ERROR>
</NATION>


I don't know why. I've made sure I've copied and pasted the right token into the token field but still, nothing is working and I keep getting this error.

This can happen if you do something between the "prepare" and "execute" requests that invalidates your current session. I sometimes get it if I'm also logged in to the website via my browser, because I have autologin enabled and it renews my session in the background.


Even after clearing my cookies on NS and closing my NS tab, it still gives me the error. I tried it on my puppet Not Doge Land 1 which I haven't logged into for like a week (besides GI farming) and it also gave me the error.
The Confederacy of Doge Land: Once oppressed by the colonizers. Now oppressing them.

Ex-delegate of Warzone Airspace. Former Cabinet Minister of the South Pacific. Apparently the latter gets me more commendation points.

Blame Quebecshire

User avatar
All Wild Things
Chargé d'Affaires
 
Posts: 402
Founded: Apr 24, 2017
Inoffensive Centrist Democracy

Postby All Wild Things » Sun Aug 29, 2021 2:33 pm

Sedgistan wrote:
All Wild Things wrote:It's more a moderation question than a technical one, but -
Is it acceptable to use this to automatically post an "Embassy update" on all my embassy RMBs (assuming their ROs consented)?
Thanks!

When new Moderation issues come up, unless the situation is serious/urgent, we tend to take a "wait and see if a problem develops" approach. So for now, you can take it that there are no particular rules on this question, besides the regular rules in the OSRS. So unless your embassy updates are spam / flaming/ trolling etc. then you should be fine to post them. We're not going to (for now) assume they are automatically spam.

Thanks for clarifying.
Browse The NewsStand
Watch the Wild Life

User avatar
Twertis
Spokesperson
 
Posts: 130
Founded: Apr 07, 2019
Ex-Nation

Postby Twertis » Mon Sep 06, 2021 12:01 pm

[violet] wrote:There are a few challenges, which you've highlighted. A concern for me is also that we don't currently offer a way for you to subscribe to events -- you can't just ask to be pinged whenever there's a new message on an RMB you're tracking. Instead, you'd need to keep polling the RMB to see if there's anything new. You'll no doubt want your bot to be responsive, so I wonder whether you're going to wind up polling a large number of regions every second or two, 99% of which is pulling the same messages over and over, just to listen for new messages. We might be able to offer a listener-based API to solve this, though.


I came here to say this. Please add an event-driven API for notices (and happenings?). In the case of an RMB bot, 30 seconds in between each notice check would probably be the maximum for a high-quality, modern bot, at least without boring the user, and in any case you'd still be "running hot". If you just didn't care about efficiency and wanted it to be responsive within the second, you could poll the site at 100 times per second. But if you wanted to add features that interact with NS' site (e.g. a nations not endorsing command for GPers, or an NSEconomy stats command for RPers), you'd run into an issue where you're balancing features and responsiveness. While this is mainly an efficiency problem, larger bots might run into quality-of-life problems.

The same could be said for happenings, which are frustrating to poll, especially if you need to get new happenings in as fast as possible (e.g. manual recruitment "accelerators" like 10KI's, Trotterdam's issues analysis). And in any case, NS already seems to have a start to a push API with automatically-updating telegrams, happenings, and notices (and NS++).

All in all, I really like this idea. I might whip up a rough draft of some general-purpose bot commands later today. And perhaps August can port NSVerify's database to NS (i.e. see a nation's discord account and other nations, if applicable).

User avatar
Indian andhra
Attaché
 
Posts: 80
Founded: May 01, 2021
Authoritarian Democracy

Postby Indian andhra » Fri Sep 10, 2021 10:06 pm

If anyone want discord to rmb contact me

User avatar
Indian andhra
Attaché
 
Posts: 80
Founded: May 01, 2021
Authoritarian Democracy

Postby Indian andhra » Mon Oct 11, 2021 6:18 pm

Is there any ratelimit for this

User avatar
Comfed
Ambassador
 
Posts: 1686
Founded: Apr 09, 2020
Psychotic Dictatorship

Postby Comfed » Mon Oct 11, 2021 6:53 pm

Indian andhra wrote:Is there any ratelimit for this

There’s always an API rate limit and considering you’re someone who has written a script for the API it’s a bit concerning that you don’t know this.
Rate Limits

The API is rate-limited and will temporarily lock you out if you send too many requests within a short period of time. (And return status 429: "Too Many Requests From Your IP Address.")

API Rate Limit: 50 requests per 30 seconds.

Traffic exceeding this rate is automatically banned for 15 minutes, so please try to stay well within it. If you make a request while rate-banned, you will receive response status 429 and the header 'X-Retry-After: n', where n is the number of seconds until you can make another request.

A "request" is an HTTP request to the site for any amount of information and any number of shards. That is, an HTTP request like this is a single request, even though it gathers information on three shards.

As per the Telegrams API documentation, an additional limit applies when sending TGs
TNP EIA
WA (Co-)Authorship: SC#390

10000 Islands Foreign Affairs wrote:~The population of 10000 Islands suffered a huge increase
Ankuran wrote:"Here's Form T-34 for issuing a bribe. Enter the recipient's name here, check reason for bribe here, enter amount here. Now we'll just swipe your card here. Would you like to join our Frequent Briber's Club? Get five percent cash back on your first bribe."
[violet] wrote:lol
Douglas Adams wrote:In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.
Fool me once, shame on you. Fool me twice, everybody dies.
Nation reflects RL beliefs, especially bad ones. All stats are canon.

User avatar
United Calanworie
Envoy
 
Posts: 232
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Tue Apr 19, 2022 4:24 pm

[violet] wrote:As a trial, I've added a Nation Private Command API for making RMB posts.

It's currently undocumented, but follow the same process as for lodging a dispatch:

https://www.nationstates.net/pages/api. ... tecommands

You'll need to send "c=rmbpost", plus these parameters: nation, region, text, mode

E.g.
Code: Select all
curl -H "X-Password: hunter2" -A "UserAgent Example" "https://www.nationstates.net/cgi-bin/api.cgi" --data "nation=testlandia&region=testregionia&c=rmbpost&text=Hello%20there.&mode=prepare"

curl -H "X-Pin: 1234567890" -A "UserAgent Example" "https://www.nationstates.net/cgi-bin/api.cgi" --data "nation=testlandia&region=testregionia&c=rmbpost&text=Hello%20there.&mode=execute&token=1234567890abcdefg"


This will automatically add a signature that says "This is an automated message," and apply some stricter flood control.

Can you please see if you can get this working? I would like all bots to operate via the API.

Bumping this several months later, but there is at least one RMB bot operating (The Moose) and I had to explain to somebody today that no, Moose was using an undocumented API private command to handle its posting. Could we get official documentation added to /pages/api.html?
Discord: Aav#7564
She/Her/Hers
My Projects:
HYPR: TG API software (GitHub) | Spyglass (forum) (GitHub) (Latest Release)

||||||||||||||||||||
||||||||||||||||||||

Previous

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Google [Bot]

Advertisement

Remove ads