-
Notifications
You must be signed in to change notification settings - Fork 1
/
moveBus1xx.js
53 lines (41 loc) · 1.32 KB
/
moveBus1xx.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Zmiana numeracji poznańskich linii autobusowych od stycznia 2019r.
*
* 52 -> 152
*/
var bot = require('nodemw'),
client = new bot('config.js');
var SUMMARY = 'Zmiana numeracji poznańskich linii autobusowych od stycznia 2019r.';
client.logIn(function() {
client.getPagesInCategory('Linie autobusowe', (err, pages) => {
var stubsFound = 0,
idx = 0;
//console.log("Pages: " + pages.length);
pages.forEach(page => {
if (page.ns !== 0) {
return;
}
var matches = page.title.match(/nr (\d+)$/),
num = matches ? parseInt(matches[1], 10) : false;
if (!num) return;
if (num < 40 || num > 99) return;
/// if (num > 75) return; // TODO
var newTitle = 'Linia autobusowa nr ' + (num + 100 + '');
console.log(page.title + ' -> ' + newTitle);
client.getArticle(page.title, (err, content) => {
// template
content = content.replace('|numer=' + num, '|numer=' + (num+100+''));
// '''Linia autobusowa nr 51'''
content = content.replace('nr ' + num + "'''", 'nr ' + (num+100+'') + "'''");
// console.log(page.title, content); return;
// replace numbers
client.edit(page.title, content, SUMMARY, () => {
// and move the page
client.move(page.title, newTitle, SUMMARY, () => {
console.log(" # " + page.title + " moved");
});
});
});
});
});
});