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]
Executive Director
 
Posts: 16205
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
Diplomat
 
Posts: 526
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
Site Director
 
Posts: 35471
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: 333
Founded: Feb 15, 2019
Psychotic Dictatorship

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.
this is a signature

User avatar
All Wild Things
Diplomat
 
Posts: 526
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
Ex-Nation

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
Ex-Nation

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

Is there any ratelimit for this

User avatar
Comfed
Minister
 
Posts: 2254
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

User avatar
United Calanworie
Technical Moderator
 
Posts: 3763
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?
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

User avatar
Ever-Wandering Souls
Negotiator
 
Posts: 7267
Founded: Jan 01, 2014
Father Knows Best State

Postby Ever-Wandering Souls » Tue Feb 21, 2023 8:26 pm

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^
Proud Raider; General of The Black Hawks, Ret.
TG me anytime; I'm always happy to talk about anything!

The Alicorns (Equestria) wrote:Let them stay, no need to badmouth them...From our view a bunch of nations just came in, seized the delegate position, and changed a few superficial things...we play NationStates differently...there's really no reason for us to be butthurt.
http://www.nationstates.net/page=rmb/postid=8944227
http://www.nationstates.net/page=rmb/postid=8951258

Misley wrote:
Hobbesistan wrote:Don't think I understand the question.
The color or what?..

Jesus, Hobbes, it's 2015. You can't just call someone "the color".

Reploid Productions wrote:Raiders are endlessly creative

How Do I Telegram API?

Omnis delenda est.

User avatar
Improper Classifications
Ambassador
 
Posts: 1313
Founded: Apr 18, 2022
Iron Fist Consumerists

Postby Improper Classifications » Wed Feb 22, 2023 5:38 am

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?
Former Acolyte of Malice
Founder and Champion of Voidcall, Conqueror of Majesty and Pentarchs.
Legally proscribed in The South Pacific under On Concord.
The Imperial Federation of Improper Classifications

User avatar
United Calanworie
Technical Moderator
 
Posts: 3763
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Wed Feb 22, 2023 9:59 am

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.
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

User avatar
Ever-Wandering Souls
Negotiator
 
Posts: 7267
Founded: Jan 01, 2014
Father Knows Best State

Postby Ever-Wandering Souls » Wed Feb 22, 2023 11:37 am

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. =)
Last edited by Ever-Wandering Souls on Wed Feb 22, 2023 11:39 am, edited 2 times in total.
Proud Raider; General of The Black Hawks, Ret.
TG me anytime; I'm always happy to talk about anything!

The Alicorns (Equestria) wrote:Let them stay, no need to badmouth them...From our view a bunch of nations just came in, seized the delegate position, and changed a few superficial things...we play NationStates differently...there's really no reason for us to be butthurt.
http://www.nationstates.net/page=rmb/postid=8944227
http://www.nationstates.net/page=rmb/postid=8951258

Misley wrote:
Hobbesistan wrote:Don't think I understand the question.
The color or what?..

Jesus, Hobbes, it's 2015. You can't just call someone "the color".

Reploid Productions wrote:Raiders are endlessly creative

How Do I Telegram API?

Omnis delenda est.

Previous

Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Addy and Arielle, Dharmasya, Gabrielos, TBH Commander, The Endless Eventide

Advertisement

Remove ads