Page 2 of 2

PostPosted: Sat Aug 28, 2021 11:28 pm
by [violet]
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.

PostPosted: Sun Aug 29, 2021 3:19 am
by All Wild Things
[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!

PostPosted: Sun Aug 29, 2021 4:16 am
by Sedgistan
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.

PostPosted: Sun Aug 29, 2021 4:47 am
by Doge Land
[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.

PostPosted: Sun Aug 29, 2021 2:33 pm
by All Wild Things
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.

PostPosted: Mon Sep 06, 2021 12:01 pm
by Twertis
[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).

PostPosted: Fri Sep 10, 2021 10:06 pm
by Indian andhra
If anyone want discord to rmb contact me

PostPosted: Mon Oct 11, 2021 6:18 pm
by Indian andhra
Is there any ratelimit for this

PostPosted: Mon Oct 11, 2021 6:53 pm
by Comfed
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

PostPosted: Tue Apr 19, 2022 4:24 pm
by United Calanworie
[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?

PostPosted: Tue Feb 21, 2023 8:26 pm
by Ever-Wandering Souls
United Calanworie wrote:
[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?


This, again^

PostPosted: Wed Feb 22, 2023 5:38 am
by Improper Classifications
Ever-Wandering Souls wrote:
United Calanworie wrote: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?


This, again^

If I recall correctly The Moose was part of August's various tools and so will probably not be updated further?

PostPosted: Wed Feb 22, 2023 9:59 am
by United Calanworie
Improper Classifications wrote:
Ever-Wandering Souls wrote:
This, again^

If I recall correctly The Moose was part of August's various tools and so will probably not be updated further?

Souls isn't asking about Moose, he's asking for the API docs to include the API private command that Moose was using.

PostPosted: Wed Feb 22, 2023 11:37 am
by Ever-Wandering Souls
Correct, this shard has been in undocumented beta for 18 months (almost to the day - later this week), and should be documented properly in the API documentation by now, whether in the current state or with any revisions driven from the beta era. Like Aav, I find myself repeatedly explaining that this shard exists and is legal to use, but not officially documented. If additional feedback is needed first, please say so to solicit it. =)