Xqt has submitted this change and it was merged. Change subject: Adding option of "-nobots" in order to filter edits of bots when people are using -recentchanges. ......................................................................
Adding option of "-nobots" in order to filter edits of bots when people are using -recentchanges. Bug: 55044 Change-Id: I49d3681e3b35c491fda6f08155c798ffdc0a8bfb --- M pagegenerators.py M wikipedia.py 2 files changed, 17 insertions(+), 7 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pagegenerators.py b/pagegenerators.py index 8decfb0..cfe273e 100644 --- a/pagegenerators.py +++ b/pagegenerators.py @@ -110,6 +110,8 @@ "-recentchanges:n" where n is the number of pages to be returned, else 100 pages are returned. +-rc-nobots Same as above but doesn't work on pages that bots have edited + -ref Work on all pages that link to a certain page. Argument can also be given as "-ref:referredpagetitle". @@ -352,9 +354,15 @@ gen = RandomRedirectPageGenerator(number=int(arg[16:])) elif arg.startswith('-recentchanges'): if len(arg) >= 15: - gen = RecentchangesPageGenerator(number=int(arg[15:])) + gen = RecentchangesPageGenerator(number=int(arg[15:]), nobots=False) else: - gen = RecentchangesPageGenerator() + gen = RecentchangesPageGenerator(nobots=False) + gen = DuplicateFilterPageGenerator(gen) + elif arg.startswith('-rc-nobots'): + if len(arg) >= 11: + gen = RecentchangesPageGenerator(number=int(arg[11:]), nobots=True) + else: + gen = RecentchangesPageGenerator(nobots=True) gen = DuplicateFilterPageGenerator(gen) elif arg.startswith('-file'): textfilename = arg[6:] @@ -587,7 +595,7 @@ yield item[0] -def RecentchangesPageGenerator(number=100, site=None): +def RecentchangesPageGenerator(number=100, site=None, nobots=False): """Generate pages that are in the recent changes list. @param number: iterate no more than this number of entries @@ -595,7 +603,7 @@ """ if site is None: site = pywikibot.getSite() - for item in site.recentchanges(number=number): + for item in site.recentchanges(number=number, nobots=nobots): yield item[0] diff --git a/wikipedia.py b/wikipedia.py index c9bc07e..3a00767 100644 --- a/wikipedia.py +++ b/wikipedia.py @@ -8117,7 +8117,7 @@ def recentchanges(self, number=100, rcstart=None, rcend=None, rcshow=None, rcdir='older', rctype='edit|new', namespace=None, includeredirects=True, repeat=False, user=None, - returndict=False): + returndict=False, nobots=False): """ Yield recent changes as Page objects uses API call: @@ -8176,9 +8176,11 @@ 'loginfo', 'sizes'], # , 'flags', 'redirect', 'patrolled'], 'rcnamespace': namespace, - 'rclimit': int(number), } - + if nobots: + params['rclimit'] = str(number) + "!bot" + else: + params['rclimit'] = int(number) if user: params['rcuser'] = user if rcstart: -- To view, visit https://gerrit.wikimedia.org/r/95327 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I49d3681e3b35c491fda6f08155c798ffdc0a8bfb Gerrit-PatchSet: 2 Gerrit-Project: pywikibot/compat Gerrit-Branch: master Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits