Posted: Wed Jul 26, 2023 2:19 pm
Not at this time, unless my colleagues have one and haven't shared it.
Because sometimes even national leaders just want to hang out
https://forum.nationstates.net/
The Ice States wrote:Why does the <COAUTHOR> tag of the proposals API shard now give strings such as "ARRAY(0x7f8d078abcc8)" instead of the actual co-authors listed in <N> tags? It returning these strings appears to be new, CF: The resolution shard.
Roavin wrote:Ever-Wandering Souls wrote:If you mean specific to the values themselves, they're largely possible to approximate as-is with the influence census, endos census, activity, and a loose approximation of the decay rate - accurately enough to get the job done at least. I do it for ops all the time. It just requires a massive pain in the ass spreadsheet of starting inf + endos at update (in or out of the region) - assumed decay, updated twice daily.
Having done this myself, I feel your pain
I'll bring the suggestion up backstage.
<CARDS>
<DECK>
<CARD>
<CARDID>1526694</CARDID>
<CATEGORY>common</CATEGORY>
<SEASON>1</SEASON>
<MARKETVALUE>0.01</MARKETVALUE>
</CARD>
...
</DECK>
</CARDS>
<CARDS>
<CARDSEASON>3</CARDSEASON>
</CARDS>
Grishahakkaverchynot wrote:I think that maybe, if you want people to stop using the HTML site to do script stuff, it might help adding RO actions as performable API actions?
Improper Classifications wrote:Is there a private API command that allows Executive regional officers to appoint and dismiss officers?
Eluvatar wrote:Grishahakkaverchynot wrote:I think that maybe, if you want people to stop using the HTML site to do script stuff, it might help adding RO actions as performable API actions?Improper Classifications wrote:Is there a private API command that allows Executive regional officers to appoint and dismiss officers?
What use case(s) would you like to support with such an API?
United Calanworie wrote:The Ice States wrote:Why does the <COAUTHOR> tag of the proposals API shard now give strings such as "ARRAY(0x7f8d078abcc8)" instead of the actual co-authors listed in <N> tags? It returning these strings appears to be new, CF: The resolution shard.
As remarked on off-site, this is due to the API going "ah yes, you *totally* wanted to have me just send the memory address of an array across the internet, didn't you?" A certified Perl classic, if you ask me.
Ideally it'll get fixed at some point in the near future.
9003 wrote:Steps to reproduce
goto/request
https://www.nationstates.net/cgi-bin/ap ... =proposals
Look at
<COAUTHOR>ARRAY(0x7f8da2748e98)</COAUTHOR>
It should be the data in the array and not the memory location of the array.
Eluvatar wrote:United Calanworie wrote:As remarked on off-site, this is due to the API going "ah yes, you *totally* wanted to have me just send the memory address of an array across the internet, didn't you?" A certified Perl classic, if you ask me.
Ideally it'll get fixed at some point in the near future.9003 wrote:Steps to reproduce
goto/request
https://www.nationstates.net/cgi-bin/ap ... =proposals
Look at
<COAUTHOR>ARRAY(0x7f8da2748e98)</COAUTHOR>
It should be the data in the array and not the memory location of the array.
A change has been drafted to fix this and should be available for your pleasurewithin a day or twonow.
Headers({'server': 'cloudflare', 'date': 'Sun, 22 Oct 2023 14:21:38 GMT', 'content-type': 'text/html', 'content-length': '175', 'connection': 'close', 'cf-ray': '-'})
Devious wrote:filter=cte seems to cover nations dying of natural causes, but not DEATs.
Frisbeeteria wrote:Devious wrote:filter=cte seems to cover nations dying of natural causes, but not DEATs.
Why do you need this? Make your case, please.
They don't appear in the Happening because we have a feature called "silent DEAT". As a general rule, we don't want to promote the offensive names we delete by posting happenings. For particularly egregious offensive nations, we actually purge all happenings (moves, issues, posts, etc) so players don't have to look at remnants of that sort of nonsense.
Devious wrote:this runs into the issue of nations DEATed between the point of collection and point of relaying being impossible to detect without significantly increasing the tool's API overhead by doing a call for each nation and discarding them on a 404 error
my thought was to reduce this by instead pulling a list of CTE'ed nations every time i pull foundings (currently on a 30m timer), and excluding any matches from my backlog, which would reduce the number of calls needed for that filter to #CTEs/100, rounded up. but as you mentioned, DEATs can't be grabbed from the happenings shard.
// Code by Epithemia
var api_version = 12;
function update() {
getEmperorEndorsers();
getCarcassonneOfficers();
getCarcassonneEndorsements();
// TODO getCitizens();
}
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Script Menu').addItem("Update Data",'update');
}
function getCarcassonneEndorsements() {
getRegionEndorsements("WA Nations","carcassonne",1,1,2);
}
function getCarcassonneOfficers() {
getRegionOfficers("Officers","carcassonne",1);
}
function getEmperorEndorsers() {
getNationEndorsers("Endorsers","ysengrim",1);
}
String.prototype.addQuery = function (obj) {
return this + "?" + Object.entries(obj).flatMap(([k, v]) => Array.isArray(v) ? v.map(e => `${k}=${encodeURIComponent(e)}`) : `${k}=${encodeURIComponent(v)}`).join("&");
}
var last_api_request = 0;
function getApiXml(params) {
var t = new Date();
params.v = api_version;
params.gdoc = SpreadsheetApp.getActiveSpreadsheet().getId();
params.useremail = Session.getActiveUser().getEmail();
Utilities.sleep(Math.max(601+last_api_request-t,0));
var response = UrlFetchApp.fetch("http://www.nationstates.net/cgi-bin/api.cgi".addQuery(params));
last_api_request = new Date().valueOf();
return XmlService.parse(response);
}
// arguments:
// sheetname: name of sheet to update
// region: name of region to query
// limit: lowest endorsement count to care about
// nation_col: column # of nation names
// ans_col: column # to put result in
function getRegionEndorsements(sheetname,regionname,limit,nation_col,ans_col) {
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
var wa_nations = [];
var start = 1;
api_loop:
while(true) {
try {
var xml = getApiXml({region, q: 'censusranks', scale: 66, start });
var nations_xml = xml.getRootElement().getChild('CENSUSRANKS').getChild('NATIONS').getChildren();
for (nation_xml of nations_xml) {
var name = nation_xml.getChild('NAME').getText();
var endos = nation_xml.getChild('SCORE').getText();
if ( endos < limit ) {
break api_loop;
}
wa_nations.push({name, endos: endos});
Logger.log('nationname '+ name + ', endos '+endos);
}
start += 20;
} catch ( err ) {
Logger.log("Error: "+ err);
return;
}
}
sheet.getRange(2,nation_col,wa_nations.length,1).setValues(wa_nations.map(({name})=> ([name])));
sheet.getRange(2,ans_col,wa_nations.length,1).setValues(wa_nations.map(({endos})=> ([endos])));
}
// arguments:
// sheetname: name of sheet to update
// region: name of region to query
// nation_col: column # of nation names
// ans_col: column # to put office name in (optional)
function getRegionOfficers(sheetname,region,nation_col,ans_col) {
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
var officer_nations = [];
try {
var xml = getApiXml({region, q: 'officers'});
var nations_xml = xml.getRootElement().getChild('OFFICERS').getChildren();
for (nation_xml of nations_xml) {
var name = nation_xml.getChild('NATION').getText();
var office = nation_xml.getChild('OFFICE').getText();
officer_nations.push({name, office})
Logger.log('nationname '+ name + ', office '+office);
}
} catch ( err ) {
Logger.log("Error: "+ err);
return;
}
sheet.getRange(2,nation_col,officer_nations.length,1).setValues(officer_nations.map(({name})=>([name])));
if( ans_col ) {
sheet.getRange(2,ans_col,officer_nations.length,1).setValues(officer_nations.map(({office})=>([office])));
}
}
// arguments:
// sheetname: name of sheet to update
// nation: name of nation to query
// nation_col: column # of endorser nation names
function getNationEndorsers(sheetname, nation, nation_col) {
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
var endorser_nations = [];
try {
var xml = getApiXml({nation, q: 'endorsements'});
endorser_nations = xml.getRootElement().getChild('ENDORSEMENTS').getText().split(',');
} catch ( err ) {
Logger.log("Error: "+ err);
return;
}
Logger.log('endorser_nations '+endorser_nations);
sheet.getRange(2,nation_col,endorser_nations.length,1).setValues(endorser_nations.map((name)=>([name])));
}
https://www.nationstates.net/cgi-bin/rss.cgi?view=region.eurth;q=happenings;filter=rmb;nation=orioni_2
https://www.nationstates.net/cgi-bin/rss.cgi?view=region.eurth;q=happenings;filter=rmb