User:Reza1615/BOT

From Wikidata
Jump to navigation Jump to search

I developed a bot which can organizing language links in locale wiki and Wikidata

Wikidata
  • adding new items if they don't exist in Wikidata for:
    • none-interwiki pages
    • with-interwiki pages which none of language links doesn't have item in Wikidata
  • updateing items in wikidata
  • adding labels according to language's interwiki
Local wiki
  • removing old interwikis which exist in Wikidata from Local wiki pages
  • adding {{interwiki conflict}} (Q6099744) in Local wiki to pages which their interwikis has conflict

This bot uses pywikipedia library + Wikidata library (below) which I updated and modified Wikidata library to have best result.

Bot Flag needed

[edit]

For running this bot you should have flag in local wiki and Wikidata

  • local wiki: (removing existed old_interwikis in Wikidata from pages) -remove argument
  • Wikidata: (creating or updating items and updating labels)

Running Bot

[edit]

This Bot only runs on linux or Toolserver computers! and for windows or mac it needs more changes.

For running this bot you should do these steps

  • ‌Be sure that you are using final version of pywikipedia library. for ToolServer account go to pywikipedia folder and type : svn update
  • copy wikidata library (below) to your pywikipedia folder
  • set your username and password in passfile
  • set your pywikipedia address in config b.py
  • set your pywikipedia address in wikidata.py
  • set your pywikipedia address in line 46 of New_interwiki.py
  • at your user_config.py set your bot like below (BotName= your bot username and xx= your wiki prefix for example en for English )
family = 'wikipedia'
mylang = 'xx'
password_file= 'passfile'
usernames['wikipedia']['xx'] = u'BotName'
usernames['wikidata']['wikidata'] = u'BotName'

This bot accepts pywikipedia standard arguments like (new, start, page, cat) also for new categories it accepts (newcat)

Updating or making items for page [[XXXX]]
python new_interwiki.py -page:XXXX
Updating or making items which the page's name starts with AB and removing existing interwikis from local wiki
python new_interwiki.py -start:AB -remove
Updating or making items for 100 new cats and removing existing interwikis from local wiki
python new_interwiki.py -newcat -remove

Reporting errors

[edit]

this bot reports two errors

  1. Item conflicts in file interwiki_conflicts.txt
  2. API errors in file interwiki_import_errors.txt
  3. Save list of empty items which is made after merging in the file zzinterwiki_import_merged_need_deleted.txt
  • Important Note: Because of changing the API URL you should do this edit in API.py file!

Code

[edit]

You can download these codes from here

New_interwiki.py

[edit]

merge-pages.py

[edit]

Library

[edit]

Problem with running the Bot

[edit]
  1. Be sure that you done #Running Bot steps