Skip to content

Commit

Permalink
now it follows 'continue' when retrieving user list
Browse files Browse the repository at this point in the history
  • Loading branch information
emijrp committed Jul 28, 2016
1 parent f5aa2a1 commit 5c8209c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions avbot.py
Expand Up @@ -66,7 +66,7 @@ def __init__(self):
self.version = self.getLocalVersion() # AVBOT version

self.wikiBotName = 'Bot', # Bot username in wiki
self.wikiManagerName = 'Manager' # Bot manager username in wiki
self.wikiBotManagerName = 'BotManager' # Bot manager username in wiki
self.wikiLanguage = 'en' # Default wiki language is English
self.wikiFamily = 'wikipedia' # Default wiki family is Wikipedia
self.site = pywikibot.Site(self.wikiLanguage, self.wikiFamily)
Expand Down Expand Up @@ -103,16 +103,16 @@ def __init__(self):
self.filters = []
self.filtersLocations = [ # Files with regexps and scores to detect vandalism
{'type': 'file', 'location': 'filters/%s.%s.filters.txt' % (self.wikiFamily, self.wikiLanguage)},
{'type': 'page', 'location': 'User:%s/filters.css' % (self.wikiBotName)},
{'type': 'page', 'location': 'User:%s/filters.css' % (self.wikiBotManagerName)},
]
self.exclusions = []
self.exclusionsLocations = [ # Files and pages that lists excluded pages (usual false positives)
{'type': 'file', 'location': 'exclusions/%s.%s.exclusions.txt' % (self.wikiFamily, self.wikiLanguage)},
{'type': 'page', 'location': 'User:%s/exclusions.css' % (self.wikiBotName)},
{'type': 'page', 'location': 'User:%s/exclusions.css' % (self.wikiBotManagerName)},
]
self.messagesLocations = [ # Files with messages to leave in talk pages
{'type': 'file', 'location': 'messages/%s.%s.messages.txt' % (self.wikiFamily, self.wikiLanguage)},
{'type': 'page', 'location': 'User:%s/messages.css' % (self.wikiBotName)},
{'type': 'page', 'location': 'User:%s/messages.css' % (self.wikiBotManagerName)},
]
self.namespaces = []
self.isAliveFile = '%s.%s.alive.txt' % (self.wikiFamily, self.wikiLanguage) # File to check if AVBOT is working
Expand All @@ -132,7 +132,7 @@ def start(self):
header += "# Report vandalism attack waves to admins #\n"
header += "# Mark rubbish articles for deletion #\n"
header += "############################################################################\n\n"
header += "Available parameters (* obligatory):\n--wikilang, --wikifamily, --newbiethreshold, --wikibotname*, --statsdelay, --ircnetwork, --ircchannel, --wikimanagername*, --nosave, --force\n\n"
header += "Available parameters (* obligatory):\n--wikilang, --wikifamily, --newbiethreshold, --wikibotname*, --statsdelay, --ircnetwork, --ircchannel, --wikibotmanagername*, --nosave, --force\n\n"
header += "Example: python avbot.py --wikibotname:MyBot --wikimanagername:MyUser\n\n"
header += u"Loading data for %s:%s project\n" % (self.wikiFamily, self.wikiLanguage)
header += u"Newbie users are those who have done %s edits or less" % (self.newbieThreshold)
Expand All @@ -142,12 +142,12 @@ def start(self):
#self.isAlive()

if self.checkForUpdates():
print("\n\03{lightred}***New code available***\03{default} Please, update your copy of AVBOT from %s\n" % (self.repo))
pywikibot.output("\n\03{lightred}***New code available***\03{default} Please, update your copy of AVBOT from %s\n" % (self.repo))
sys.exit()

""" Data loaders """
#self.loadUsers()
#self.loadExclusions()
self.loadUsers()
self.loadExclusions()

"""Messages"""
"""avbotload.loadMessages()
Expand Down Expand Up @@ -188,7 +188,7 @@ def loadUsers(self):
print("Loading info for users")

# Load whitelisted users by group
with open(self.usersWhiteListFile) as f:
with open('%s/users/%s' % (self.path, self.usersWhiteListFile)) as f:
for row in f.read().strip().splitlines():
x, y = row.split(',')
if y == 'group':
Expand Down Expand Up @@ -219,7 +219,6 @@ def loadUsersByGroup(self, group='', whitelisted=False):
while aufrom:
query = pywikibot.data.api.Request(parameters={'action': 'query', 'list': 'allusers', 'augroup': group, 'aulimit': '500', 'aufrom': aufrom}, site=self.site)
data = query.submit()
#print(data)
if 'query' in data and 'allusers' in data['query']:
for row in data['query']['allusers']:
username = row['name']
Expand All @@ -229,8 +228,10 @@ def loadUsersByGroup(self, group='', whitelisted=False):
self.users[username] = {'groups': [group]}
self.users[username]['whitelisted'] = whitelisted
c += 1
if 'continue' in data and 'aufrom' in data['continue']:
aufrom = data['continue']['aufrom']
if 'query-continue' in data and \
'allusers' in data['query-continue'] and \
'aufrom' in data['query-continue']['allusers']:
aufrom = data['query-continue']['allusers']['aufrom']
else:
aufrom = ""
else:
Expand Down

0 comments on commit 5c8209c

Please sign in to comment.