kanasimi / wikiapi

JavaScript MediaWiki API for node.js
https://kanasimi.github.io/wikiapi/
BSD 3-Clause "New" or "Revised" License
48 stars 6 forks source link

[[*/Stop]] #16

Closed hugolpz closed 3 years ago

hugolpz commented 3 years ago

In console I see :

wiki_API_page: Not exists: [[User talk:Dragons Bot@Dragons Bot/Stop]]

We should expect :

wiki_API_page: Not exists: [[User talk:Dragons Bot/Stop]]

no ?

kanasimi commented 3 years ago

The code is at https://github.com/kanasimi/CeJS/blob/master/application/net/wiki/page.js#L584 Usually it should be [[User talk:Dragons Bot/Stop]]

The page title is 'User talk:' + token.lgname + '/Stop' @ https://github.com/kanasimi/CeJS/blob/master/application/net/wiki/edit.js#L161 Maybe the token.lgname is "Dragons Bot@Dragons Bot"? You may check it with console.log(wiki_session) and try to find .token

hugolpz commented 3 years ago

Yes, USER='Dragons Bot@Dragons_Bot' for sure. It's the value I use, as provided by Special:PasswordBots. It means User:Dragons Bot (human with mouse) generated a password for User:Dragons_Bot (bot account). I also have Yug@Dragons_Bot and associated password. The /stop should be attached to the bot account User:Dragons_Bot, not to the connection credential Yug@Dragons_Bot. Then var bot = str.split('@')[1]; I guess.


I got ReferenceError: wiki_session is not defined. Where do you put console.log(wiki_session) ?

    // Connect
    const targetWiki = new Wikiapi;
    await targetWiki.login(USER, PASS, API);

    // do nothing but log
    await targetWiki.edit_page('User:Yug', function(page_data) {
        console.log(wiki_session)
        return page_data;
    }, {bot: 1, minor: 1, summary: 'test edit'});

})();
FabulousCupcake commented 3 years ago

This should be documented somewhere; I was confused why the library is screaming about /Stop page not existing, only to find out after digging for ~30 minutes that it seems to be a hardcoded/arbitrary way to stop the bot.

hugolpz commented 3 years ago

It's a Wikimedia best practice : a conventional button, which provides via the right url a very quick access to the admin page to block that bot.

There is a push to produce a clear documentation (#30). Still needs about a week for the core 90%. Then few months to add sugars. 👍🏼

FabulousCupcake commented 3 years ago

I did read over https://www.mediawiki.org/wiki/Manual:Bots and found no mentions about the Stop page, hence the confusion, but glad to hear there's plans to improve docs 👍

hugolpz commented 3 years ago

You are able to make it run right ? Your bot is on github ?

FabulousCupcake commented 3 years ago

Yes; It did not block anything, just produced mildly annoying "Stop page not found" on/after every edit.
Creating the page and writing something in it silenced the output.