SuLab / WikidataIntegrator

A Wikidata Python module integrating the MediaWiki API and the Wikidata SPARQL endpoint
MIT License
244 stars 46 forks source link

UA should include name of Bot being operated #75

Closed addshore closed 5 years ago

addshore commented 6 years ago

Right now the default UA is simply "wikidataintegrator: github.com/SuLab/WikidataIntegrator"

In relation to https://phabricator.wikimedia.org/T199662 it would be great if when operated as part of a bot the bot name or user was automatically included as part of the UA.

Other libraries and bots already seem to do this such as Pywikibot

stuppie commented 6 years ago

Do you have a suggested format? Ah, found this: https://meta.wikimedia.org/wiki/User-Agent_policy

stuppie commented 6 years ago

Currently users can already set their own user-agent upon initialization (https://github.com/SuLab/WikidataIntegrator/blob/9ba41fab73ba34fe5a2b13a07dab09efbdb7ba2f/wikidataintegrator/wdi_core.py#L58). This isn't required though. I could change it so that if the user logs in with a username and password, their username gets added to the UA. However, with the caveat if they log in using oath, it wouldn't be there. How does pywikibot get the tool name? Does it require users to set their UA before they can run?

stuppie commented 6 years ago

Added version # and username (if given) https://github.com/SuLab/WikidataIntegrator/commit/18a7c8df9fc614301307ccfb834bba7a1496e6e6 Example: User-Agent: wikidataintegrator/0.0.555 (User:gstupp)