Page MenuHomePhabricator

Edits done by Pywikibot are not flagged as made by bot
Open, Needs TriagePublic


I'm using Pywikibot to batch upload files to Fandom and then chnage their categories and add a template using "upload", "category" and "add_text" scripts.
Everything works fine except one thing - edits done via Pywikibot are not marked as done by bot, so they show up on "Recent changes" page even with "Human (not bot)" filter on, which leads to flooding this list with edits done by me.
I wrote asking about it to Fandom staff and they replied the following

we aren't as familiar with that tool - but there's a specific API flag that has to be sent as well as us setting the account as a bot.

Do you believe you are sending that API flag?

Unfortunately I wasn't able something clear about it, there are some mentioning in documentation but that's all. I tried editing def save in page/, setting botflag: Optional[bool] to True, but to no avail. Changing minor: bool to False works though, edits done by bot are no longer flagged as minor.

Is there something that I'm missing or is it a bug?

Output of verison

Pywikibot: [https] r-pywikibot-core.git (a07ced0, g13923, 2020/12/22, 14:06:50, stable)
Release version: 5.3.0
requests version: 2.22.0
  cacerts: /etc/ssl/certs/ca-certificates.crt
    certificate test: ok
Python: 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]

Event Timeline

Please link to a specific recent changes. Does your bot account have bot flag?

Please link to a specific recent changes.
Name of my bot is Red Khan Bot

Does your bot account have bot flag?

It does. Fandom staff says so and I'm able to make changes via bot.

Amire80 added a subscriber: Amire80.

It happens on the level of the account, not on the level of the software you use to make edits. The Red_Khan_Bot must be added to the bots group, and then all its edits will be marked as bot edits, whether you make them using pywikibot or the usual interactive editing interface.

Xqt added a subscriber: Xqt.

Reopened because Red_Khan_Bot is a member of bot class
but bot flag seems not beeing set.

@RedKhan16: could you please verify the bot flag right for your bot via userinfo content e.g. like:

>>> import pywikibot
>>> site = pywikibot.Site()
>>> site.sitename
>>> info = site.userinfo
>>> info['name']
>>> info['groups']
['*', 'user', 'autoconfirmed']

@Xqt Sorry, took me some time to figure out how to use the API.

Request /api.php?action=query&format=json&meta=userinfo&uiprop=blockinfo%7Cgroups%7Crights%7Chasmsg
Made it using the API Sandbox.


    "batchcomplete": "",
    "query": {
        "userinfo": {
            "id": 47783138,
            "name": "Red Khan Bot",
            "groups": [
            "rights": [

@RedKhan16: I meant to use the Pywikibot to detect the API response like that sample given above.

@Xqt: Didn't know at the moment that >>> means python CLI

>>> import pywikibot
>>> site = pywikibot.Site('ageofempires:en')
>>> site.sitename
>>> info = site.userinfo
>>> info['name']
'Red Khan Bot'
>>> info['groups']
['bot', '*', 'user', 'autoconfirmed']

Had to run python3 login otherwise it won't show me as logged in.