Good work!

> use the env variable PYWIKIBOT_DIR

Oh. At one time I was using two accounts at one site and I used a
script to copy the wanted user-config.py to the pywikibot directory.
If I need that again, I'll try to remember to use the env variable.

On Wed, Sep 7, 2022 at 4:15 PM Erik Sommer <ersot...@posteo.de> wrote:
>
> Thanks Johnuniq and also xqt for the good hints,
>
> at last I found my mistake. I'm operating two bot accounts at the
> moment. One does all the heavy lifting, but hasn't any sysop rights. The
> other one is for sysop actions only (was a wish by the community).
>
> The solution provided by piwikibot is to use the env
> variable PYWIKIBOT_DIR. I did that to point to the alternative
> user-config. But I made a mistake and I kid you not: A leading
> whitespace infront of the variable :facepalm: ... therefor the framework
> fall back to the normal pywikibot config path and loaded the config of
> the non-sysop bot :-(.
>
> Thanks to all for the help
>
> Cheers Erik
>
> On 06.09.22 11:38, Johnuniq wrote:
> > I upgraded all my pip modules yesterday, including pywikibot. Your
> > line numbers are 18 lines different from mine in _pages.py so you
> > might upgrade although that is unlikely to help.
> >
> > Browsing around the source shows that @need_right('protect') is in
> > site/_apisite.py and is responsible for the message: 'User "None" does
> > not have required user right "protect"'.
> >
> > site/_basesite.py returns None if self.logged_in() tests as false. My
> > guess is that you are not logged in and it looks like it would be easy
> > to stuff up Special:OAuthConsumerRegistration. I would try manually
> > entering lines of code into python to mimic a simple bot start-up,
> > then see if site.user() shows the bot name.
> >
> > On Tue, Sep 6, 2022 at 4:04 PM Erik Sommer <ersot...@posteo.de> wrote:
> >> This experiment was the initial reason for my post. I have one bot
> >> configured and I tried to protect some pages. This is stack trace from
> >> this experiment:
> >>
> >>     File "/home/esommer/workspace/WS_THEbotIT/service/protect.py", line
> >> 47, in task
> >>       lemma.protect(reason="Schutz fertiger Seiten",
> >>     File
> >> "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/page/_pages.py",
> >> line 1998, in protect
> >>       self.site.protect(self, protections, reason, **kwargs)
> >>     File
> >> "/home/esommer/workspace/WS_THEbotIT/venv/lib/python3.10/site-packages/pywikibot/site/_decorators.py",
> >> line 89, in callee
> >>       raise UserRightsError('User "{}" does not have required '
> >> pywikibot.exceptions.UserRightsError: User "None" does not have required
> >> user right "protect"
> >>
> >> The User "None" seems concerning. Is there a chance I screwed up the
> >> scopes when I generated the OAuth token at
> >> https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose/oauth2?
> >>
> >> Cheers Erik
> >>
> >> On 06.09.22 07:42, Johnuniq wrote:
> >>> I don't know but many years ago I ran an admin bot on a non-WMF wiki.
> >>> A separate sysopnames variable was used to specify a user with admin
> >>> credentials. Sysopnames was removed from pywikibot and whereas I've
> >>> never used it, the theory is that now you have only a single bot user
> >>> as defined in usernames. Pywikibot uses that user for normal actions
> >>> and for admin actions. If admin privilege is needed, I think it first
> >>> checks if the user has the required privilege. Some info on what I'm
> >>> saying is at
> >>> https://www.mail-archive.com/pywikibot@lists.wikimedia.org/msg00712.html
> >>>
> >>> So if you had
> >>> usernames['wikisource']['de'] = 'Example'
> >>>
> >>> where Example has the bot and sysop flags, it should work. Try a
> >>> simple script to delete a junk user subpage and report what happens. I
> >>> don't know if it's possible with MediaWiki, but it's conceivable that
> >>> pywikibot does not give itself admin credentials unless required
> >>> (which might explain your debug results).
> >>>
> >>> Johnuniq
> >>>
> >>> On Tue, Sep 6, 2022 at 3:43 AM Erik Sommer <ersot...@posteo.de> wrote:
> >>>> No worries,
> >>>>
> >>>> I do software dev for a living. It's all local and no one is checking in 
> >>>> credentials. But that wasn't really the question here.
> >>>>
> >>>> On 05.09.22 17:21, Roy Smith wrote:
> >>>>
> >>>> I'm a total newbie at pywikibot, but let me address the general issue of 
> >>>> putting credentials in config files.
> >>>>
> >>>> Be very wary of how you store credentials.  You should make sure they're 
> >>>> in a file which is read-protected, and not in source control.  Otherwise 
> >>>> the entire world will have access to your secret credentials.
> >>>>
> >>>>
> >>>>
> >>>> On Sep 5, 2022, at 10:14 AM, Erik Sommer <ersot...@posteo.de> wrote:
> >>>>
> >>>> Hi list,
> >>>>
> >>>> I operate currently a bot on the German Wikisource. The bot was granted 
> >>>> both groups, admin and bot. It is intended to be used as automated 
> >>>> protection bot. I'm having trouble to put the right credentials in my 
> >>>> user-config.py.
> >>>>
> >>>> It is currently coded like following pseudo-code:
> >>>>
> >>>> # -*- coding: utf-8 -*-
> >>>>
> >>>> family = 'wikisource'
> >>>> mylang = 'de'
> >>>> usernames['wikisource']['de'] = '******'
> >>>>
> >>>> authenticate['de.wikisource.org'] = (....*****.....)
> >>>>
> >>>> the problem with this is that the framework only detect my bot as bot 
> >>>> not as sysadmin. Groups taken from the debugging output: ['bot', '*', 
> >>>> 'user', 'autoconfirmed']
> >>>>
> >>>> What do I have to add to my config, that the bot also get picket up as 
> >>>> sysadmin? I already read 
> >>>> (https://www.mediawiki.org/wiki/Manual:Pywikibot/user-config.py) but 
> >>>> doesn't make sense for me. It will not change anything if add the 
> >>>> botname a second time to the usernames dictionary.
> >>>>
> >>>> Best Regards
> >>>>
> >>>> Erik Sommer
> >>>>
> >>>> _______________________________________________
> >>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> >>>> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
> >>>>
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> >>>> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
> >>>>
> >>>> _______________________________________________
> >>>> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> >>>> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
> >>> _______________________________________________
> >>> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> >>> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
> >> _______________________________________________
> >> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> >> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
> > _______________________________________________
> > pywikibot mailing list -- pywikibot@lists.wikimedia.org
> > To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
> _______________________________________________
> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org

Reply via email to