-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from macbre/typing/more
Add more types: SearchResult and UserContribution
- Loading branch information
Showing
5 changed files
with
59 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
// @ts-check | ||
/** | ||
* Example script getting contributions done by Pyrabot | ||
*/ | ||
'use strict'; | ||
|
||
const Bot = require( '..' ), | ||
client = new Bot( { | ||
server: 'poznan.wikia.com' | ||
} ); | ||
const Bot = require( '..' ); | ||
const client = new Bot( { | ||
server: 'poznan.wikia.com' | ||
} ); | ||
|
||
client.getUserContribs( { | ||
user: 'Pyrabot' | ||
}, function ( err, data ) { | ||
if ( err ) { | ||
console.error( err ); | ||
} else { | ||
console.log( data ); | ||
const contrib = data[ 0 ]; | ||
console.log( `${contrib.user} made an edit to ${contrib.title} on ${contrib.timestamp} (${contrib.comment}).` ); | ||
} | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
// @ts-check | ||
/** | ||
* Example script getting MW version | ||
*/ | ||
'use strict'; | ||
|
||
const Bot = require( '..' ), | ||
wikipedia = new Bot( { | ||
server: 'pl.wikipedia.org', | ||
path: '/w', | ||
debug: true | ||
} ); | ||
const Bot = require( '..' ); | ||
|
||
const wikipedia = new Bot( { | ||
server: 'pl.wikipedia.org', | ||
path: '/w' | ||
// debug: true | ||
} ); | ||
|
||
wikipedia.search( 'Tórshavn', ( err, results ) => { | ||
wikipedia.log( 'Search results:', results ); | ||
if ( err ) { | ||
console.error( err ); | ||
return; | ||
} | ||
|
||
console.log( `Got ${results.length} results:` ); | ||
|
||
results.slice( 0, 25 ).forEach( ( res ) => { | ||
console.log( `* ${res.title}` ); | ||
} ); | ||
|
||
// wikipedia.log( 'Search results:', results.slice(0, 5) ); | ||
|
||
// const { dumpObjectTypes } = require( '../lib/utils'); | ||
// dumpObjectTypes('SearchResult', results[0]); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters