else: awesome_people.append(steward) print(accounts, ips, awesome_people, mark_done) if not mark_done or len(awesome_people) == 0: continue # remove duplicates awesome_people = ', '.join(list(dict.fromkeys(awesome_people))) if mark_done: status.add(1, 'done') section.append(": '''Robot clerk note:''' {{done}} by " + awesome_people + '. ~~~~\n') print('Marking as done', awesome_people, status, ips, accounts) new_text = str(parsed) new_text = remove_empty_lines_before_replies(new_text) if (new_text != page_text and self.should_edit() and (not self.is_manual_run or confirm_edit())): api.site.login() page.text = new_text page.save(self.get_task_configuration('summary'), botflag=self.should_use_bot_flag()) self.record_trial_edit() task_registry.add_task( StewardRequestTask(5, 'Steward request bot', 'meta', 'meta'))
print( 'Removing %s requests from page %s' % (str(removed_length), page.title(as_link=True)) ) if self.should_edit() and not self.is_manual_run or manual_run.confirm_edit(): page.text = new_text page.save(summary, botflag=self.should_use_bot_flag()) self.record_trial_edit() def run(self): api = self.get_mediawiki_api() replicadb = ReplicaDatabase(api.get_site().dbName()) replicadb.request() if self.get_task_configuration('run') is not True: print('Disabled in configuration') return for page in self.get_task_configuration('pages'): print() print('--- Processing page', page) self.process_page(page, api, replicadb) replicadb.close() task_registry.add_task( FiwikiRequestedArticlesTask(2, 'Requested articles clerk', 'fi', 'wikipedia') )
block_data=block, ) raise Exception('Failed loading bot data for ' + username + ': ' + str(data)) def run(self): api = self.get_mediawiki_api() table = str(TABLE_HEADER) for user in api.get_site().allusers(group='bot'): delay = create_delay(5) username = user['name'] print('Loading data for bot', username) try: data = self.get_bot_data(username) table += data.to_table_row() except Exception as e: # TODO: make better error handling print(e, file=sys.stderr) # to not create unnecessary lag, let's process max 1 bot in 5 seconds as speed is not needed on cronjobs delay.wait() table += '|}' page = api.get_page(PAGE_NAME) page.text = table page.save('Bot updating status report', botflag=self.should_use_bot_flag()) task_registry.add_task(BotStatusTask(3, 'Bot status report', 'en', 'wikipedia'))
api = self.get_mediawiki_api() site = api.get_site() replicadb = ReplicaDatabase(site.dbName()) replag = replicadb.get_replag() if replag > 10: print('Replag is over 10 seconds, not processing! (' + str(replag) + ')') return results = replicadb.get_all(QUERY) print('-- Got %s pages' % (str(len(results)))) for page_from_db in results: if not self.should_edit(): print("Can't edit anymore, done") break page_id = page_from_db[0] page_name = page_from_db[1].decode('utf-8') page = api.get_page('Talk:' + page_name) assert page.pageid == page_id self.process_page(page) task_registry.add_task( DykEntryTalkTask(6, 'DYK entry filler', 'en', 'wikipedia'))
results = replicadb.get_all(QUERY) print('-- Got %s pages' % (str(len(results)))) for page_from_db in results: page_id = page_from_db[0] page_name = page_from_db[1].decode('utf-8') page = api.get_page(page_name) page_text = page.get() assert page.pageid == page_id print('Tagging page ', page.title()) new_text = self.get_task_configuration('autosetup_tag') + '\n\n' + page_text if ( new_text != page_text and self.should_edit() and (not self.is_manual_run or confirm_edit()) ): api.site.login() page.text = new_text page.save( self.get_task_configuration('autosetup_summary'), watch=False, minor=False, botflag=self.should_use_bot_flag(), ) self.record_trial_edit() task_registry.add_task(AchieverBot(4, 'Archive utility', 'sq', 'wikipedia'))