Page MenuHomePhabricator

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

Description

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/__init__.py, 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.

https://ageofempires.fandom.com/wiki/Special:RecentChanges
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
see: https://ageofempires.fandom.com/wiki/Special:Log?type=rights&user=&page=Red_Khan_Bot&wpdate=&tagfilter=&subtype=
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
'wikipedia:de'
>>> info = site.userinfo
>>> info['name']
'Testuser'
>>> 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.

Result

{
    "batchcomplete": "",
    "query": {
        "userinfo": {
            "id": 47783138,
            "name": "Red Khan Bot",
            "groups": [
                "bot",
                "*",
                "user"
            ],
            "rights": [
                "bot",
                "autoconfirmed",
                "editsemiprotected",
                "nominornewtalk",
                "autopatrol",
                "suppressredirect",
                "apihighlimits",
                "writeapi",
                "skipcaptcha",
                "welcomeexempt",
                "createaccount",
                "read",
                "edit",
                "createpage",
                "createtalk",
                "viewmywatchlist",
                "editmywatchlist",
                "viewmyprivateinfo",
                "editmyprivateinfo",
                "editmyoptions",
                "createnewwiki",
                "insights",
                "tagsreport",
                "renameuser",
                "dumpsondemand",
                "portabilitydashboard",
                "abusefilter-view",
                "abusefilter-log",
                "articlecomments",
                "geocode",
                "move",
                "move-subpages",
                "move-rootuserpages",
                "move-categorypages",
                "movefile",
                "upload",
                "reupload",
                "reupload-shared",
                "minoredit",
                "editmyusercss",
                "editmyuserjson",
                "editmyuserjs",
                "purge",
                "sendemail",
                "applychangetags",
                "changetags",
                "createclass",
                "torunblocked",
                "content-review-test-mode",
                "templatedraft",
                "upload_by_url",
                "wikifeaturesview",
                "edittemplates",
                "forums:read",
                "opengraph:create",
                "polls:vote",
                "posts:create",
                "posts:edit",
                "posts:report",
                "posts:vote",
                "threads:create",
                "threads:edit",
                "wall:edit"
            ]
        }
    }
}

@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
'ageofempires:en'
>>> info = site.userinfo
>>> info['name']
'Red Khan Bot'
>>> info['groups']
['bot', '*', 'user', 'autoconfirmed']

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