Giter Club home page Giter Club logo

mediawiki's People

Contributors

oliver-moran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mediawiki's Issues

feature request: handle continuations for queries

It would be handy if this library handled query continuations when the number of results requested is greater than the max limit for the request on the API's side. Basically, checking the returned parameter "query-continue", re-running the search starting from that identifier, and appending the results until "query-continue" is empty.

login error

{ error: { code: 'mustpostparams', info: 'The following parameter was found in the query string, but must be in the POST body: lgpassword.', '*': 'See http://wiki-test:8080/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.' } }

Error when page is not existant

I am currently working on a Discord Bot, which should send the user the text of a page, if it exists. If it doesn't exist, it should give the user an error message. Sending the text for pages works fine, but if a page doesn't exist, the bot just crashes and prints out

How can I stop the application from crashing and make it do something, if the page doesn't exist?

TypeError is thrown when attempting to post to mediawiki

When I try this:

var MediaWiki = require('mediawiki');

var bot = new MediaWiki.Bot({
    endpoint: "https://en.wikipedia.org/w/api.php",
    rate: 60e3 / 10,
    userAgent: "ExampleBot <https://en.wiktionary.org/wiki/User:Example>",
    byeline: "(example bot edit)"
});

bot.login('my_username', 'my_password').complete(function (username) {
    console.log(['Username:', username].join(' '));

    bot.edit('User:My_Page', 'Testing via API', 'This is a test.')
        .complete(function (title, revision, date) {
            console.log(title);
            console.log(revision);
            console.log(date.toString());
        }).error(function (err) {
            console.log('Error');
            console.log(err); 
        });
});

I get this:

TypeError: Cannot read property 'result' of undefined
    at Bot.<anonymous> (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/mediawiki.js:485:34)
    at Bot._processResponse (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/mediawiki.js:227:29)
    at Request._callback (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/mediawiki.js:179:34)
    at Request.self.callback (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/node_modules/request/request.js:978:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/node_modules/request/request.js:929:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16

When I console.log the data variable on line 484 of mediawiki.js, I get:

Username: my_username
{ servedby: 'mw1189',
  error: 
   { code: 'mustposttoken',
     info: 'The \'token\' parameter was found in the query string, but must be in the POST body',
     '*': 'See https://en.wikipedia.org/w/api.php for API usage' } }

Login error

/home/runner/MyBot/node_modules/mediawiki/mediawiki.js:50
    Promise.prototype._onError = function (err) { throw err; };
                                                  ^

Error: 301
    at Request._callback (/home/runner/MyBot/node_modules/mediawiki/mediawiki.js:181:46)
    at Request.self.callback (/home/runner/MyBot /node_modules/mediawiki/node_modules/request/request.js:121:22)
    at Request.emit (events.js:314:20)
    at Request.EventEmitter.emit (domain.js:483:12)
    at Request.<anonymous> (/home/runner/MyBot/node_modules/mediawiki/node_modules/request/request.js:978:14)
    at Request.emit (events.js:326:22)
    at Request.EventEmitter.emit (domain.js:483:12)
    at IncomingMessage.<anonymous> (/home/runner/MyBot/node_modules/mediawiki/node_modules/request/request.js:929:12)
    at IncomingMessage.emit (events.js:326:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
repl process died unexpectedly: exit status 1

Is my result trying to run:

const MediaWiki = require( 'mediawiki' );
var MyBot = new MediaWiki.Bot( {
    endpoint: "https://www.mywiki.com/api.php",
    rate: 5000,
    userAgent: "MyBot <https://mywiki.com/page/User:MyBot>"
} );

MyBot
  .login( process.env.WIKI_USERNAME, process.env.WIKI_PASSWORD )
  .complete( function ( username ) {
    console.log( 'Logged in to MyWiki as %s', username );
} );

I'm running:

New functions

Can you add new functions for move, delete, add/remove watchlist, protect/unprotecting pages? Most importantly, moving and deleting pages. would be very useful.

Cannot create redirect

Whenever I try to add a redirect, I get the following error stack. I can create/overwrite a page just fine, however it fails when I set the content to "#REDIRECT [["+message.gamename+"]]" (message.gamename has been sucessfully used previously in the same script as the title of an article, so the problem isn't there). When I escape # with a \, I get the same issue.

TypeError: Cannot read property '0' of undefined
    at /home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:480:69
    at Array.forEach (native)
    at Bot.<anonymous> (/home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:477:19)
    at Bot._processResponse (/home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:227:29)
    at Request._callback (/home/efreak/chatbot-efreak/node_modules/mediawiki/mediawiki.js:179:34)
    at Request.self.callback (/home/efreak/chatbot-efreak/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/home/efreak/chatbot-efreak/node_modules/request/request.js:978:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/efreak/chatbot-efreak/node_modules/request/request.js:929:12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.