GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kanasimi/wikibot: Some MediaWiki bot examples including wikipedia, wikidata using MediaWiki module of CeJS library. 採用 CeJS MediaWiki 自動化作業用程式庫來製作 MediaWiki (維基百科/維基數據) 機器人的範例。

BranchesTags
Open more actions menu

Latest commit

 

History

3,151 Commits
3,151 Commits

Folders and files

NameName
Last commit message
Last commit date
IRC
IRC
 
 
archive
archive
 
 
replace
replace
 
 
routine
routine
 
 
task
task
 
 
wikitech
wikitech
 
 
README.md
README.md
 
 
check_parser.js
check_parser.js
 
 
package.json
package.json
 
 
special page configuration.js
special page configuration.js
 
 
traversal_pages.js
traversal_pages.js
 
 
wiki configuration.sample.js
wiki configuration.sample.js
 
 
wiki loader.js
wiki loader.js
 
 

Repository files navigation

GitHub commit activity the past week, 4 weeks, year

CeJS MediaWiki bots demo

Some MediaWiki bot examples including wikipedia, wikidata using MediaWiki module of CeJS library and wikiapi. 採用 CeJS MediaWiki 自動化作業用程式庫來製作 MediaWiki (維基百科/維基數據) 機器人的範例。

You might also be interested in wikiapi.

Node.js usage

Installation

  1. Please install node.js and 7-Zip 18.01+.
  2. Creating a working directory and extracting files via executing commands under Windows:
npm i gh-updater
node_modules\.bin\gh-updater kanasimi/wikibot
cd wikibot-master
npm i wikiapi
copy "wiki configuration.sample.js" "wiki configuration.js"

Or under Linux:

npm i gh-updater
node_modules/.bin/gh-updater kanasimi/wikibot
cd wikibot-master
npm i wikiapi
cp "wiki configuration.sample.js" "wiki configuration.js"
  1. Setup wiki configuration.js: Edit wiki configuration.js and fill username / password.

Execution

Let's try it:

$ node
// Load CeJS library.
require('cejs');

// Load modules.
CeL.run([ 'application.net.wiki', 'application.net.wiki.data', 'application.net.wiki.admin' ]);

// Set default language. 改變預設之語言。
CeL.wiki.set_language('en');

// Set up the wiki instance.
var wiki = CeL.wiki.login(user_name, password, 'en');

wiki
// Select page(s) and get the contents of the page(s).
.page('Wikipedia:Sandbox')

// Replace the contents of a page.
.edit('wikitext to replace', {
	nocreate : 1
})

// Add a new section to a normal page or a Flow page.
.edit(': text to add.', {
	section : 'new',
	sectiontitle : 'Sandbox test section',
	summary : 'Sandbox test edit (section)',
	nocreate : 1
})

// Modify the page contents.
.edit(function(page_data) {
	/** {String}page title */
	var title = CeL.wiki.title_of(page_data),
	/** {String}page content, maybe undefined. */
	content = CeL.wiki.content_of(page_data);
	// append a new section
	return content + '\n== New section ==\n: text to add.';
}, {
	summary : 'summary'
});

wiki.categorymembers(category_title, function(page_data_list, error) {
	;
}, {
	limit : 'max'
});
  • An example for wiki_session.query()
  • An example for CeL.wiki.query()

Wikidata example:

// Cache the id of "性質" first. 先快取必要的屬性id值。
CeL.wiki.data.search.use_cache('性質', function(id_list) {
	// Get the id of property '性質' first.
	// and here we get the id of '性質': "P31"
	CeL.log(id_list);
	// 執行剩下的程序. run rest codes.
}, {
	must_callback : true,
	type : 'property'
});

// ----------------------------
// rest codes:

// Set up the wiki instance.
var wiki = CeL.wiki.login(user_name, password, 'zh');

wiki.data('維基數據沙盒2', function(data_JSON) {
	data_JSON.value('性質', {
		// resolve wikibase-item
		resolve_item : true
	}, function(entity) {
		// get "Wikidata Sandbox"
		CeL.log(entity.value('label', 'en'));
	});
});

// Old style. The same effect as codes above.
wiki.data('維基數據沙盒2', function(data_JSON) {
	wiki.data(data_JSON.value('性質'), function(entity) {
		// via wikidata_entity_value()
		// get "维基数据测试沙盒"
		CeL.log(entity.value('label'));
	});
});

// edit properties
wiki.edit_data(function(entity) {
	// add new / set single value with references
	return {
		生物俗名 : '維基數據沙盒2',
		language : 'zh-tw',
		references : {
			臺灣物種名錄物種編號 : 123456,
			// [[d:Special:AbuseFilter/54]]
			// 導入自 : 'zhwikipedia',
			載於 : '臺灣物種名錄物種',
			來源網址 : 'https://www.wikidata.org/',
			檢索日期 : new Date
		}
	};

	// set multiple values
	return {
		labels : {
			ja : 'ウィキデータ・サンドボックス2',
			'zh-tw' : [ '維基數據沙盒2', '維基數據沙盒#2', '維基數據沙盒-2' ]
		},
		descriptions : {
			'zh-tw' : '作為沙盒以供測試功能'
		},
		claims : [ {
			生物俗名 : [ 'SB2#1', 'SB2#2', 'SB2#3' ],
			multi : true,
			language : 'zh-tw',
			references : {
				臺灣物種名錄物種編號 : 123456
			}
		}, {
			読み仮名 : 'かな',
			language : 'ja',
			references : {
				'imported from Wikimedia project' : 'jawikipedia'
			}
		} ]
	};

	// remove specified value 生物俗名=SB2
	return {
		生物俗名 : 'SB2',
		language : 'zh-tw',
		remove : true
	};

	// to remove ALL "生物俗名"
	return {
		生物俗名 : CeL.wiki.edit_data.remove_all,
		language : 'zh-tw'
	};

}, {
	bot : 1,
	summary : 'bot test: edit properties'
});

Screenshot

Screenshot of WPCHECK.js (fix_16 only):

  • Output on console: On console

  • Log page on Wikipedia (ページ上への作業ログ出力): Log page

  • The contributions: Contributions

Features of CeJS MediaWiki module

  • Batch processing.

  • Access and edit wikimedia sister projects + wikidata.

  • Support Flow page: Using the same way adding section to normal page and Flow page.

  • Detection of edit conflicts and {{bots}}.

  • Query list of backlinks, embeddedin, imageusage, linkshere, fileusage, et al.

  • Parse wikitext and modify wikitext inplace.

  • Listen to recent changes with diff function supported.

  • Parse XML file of Wikimedia database backup dumps.

  • Import Wikimedia database backup dumps data to user-created database on Tool Labs. (See process_dump.js)

  • Traversal all 1.5M pages of zhwiki in 12 minutes on Tool Labs. (See traversal_pages.clear.js. It will automatically download xml dump file first.) 12分鐘遍歷所有 zhwiki 頁面。(於 Tool Labs,將自動先下載 xml dump file。)

About

Some MediaWiki bot examples including wikipedia, wikidata using MediaWiki module of CeJS library. 採用 CeJS MediaWiki 自動化作業用程式庫來製作 MediaWiki (維基百科/維基數據) 機器人的範例。

Topics

cejsmediawikimediawiki-botwikiwikidatawikipediawikipedia-botwikitext

Resources

Readme
Activity

Stars

30 stars

Watchers

4 watching

Forks

8 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.