Content deleted Content added
Updating source) (bot |
Updating source) (bot |
||
Line 1:
Source as of 00:
== Sandbot1.py ==
Line 113:
from wikibot import WikiBot
from datetime import datetime, timedelta
from threading import
import sys
import os
Line 123:
api.login(user, pw)
api.set_all()
reset_text = """
{{Please leave this line alone (sandbox heading)}}<!-- * Welcome to the sandbox! *
* Please leave this part alone *
Line 131 ⟶ 132:
"""
sandboxes = ("Wikipedia:Sandbox", "Wikipedia:Tutorial/Editing/sandbox", "Wikipedia:Tutorial/Formatting/sandbox", "Wikipedia:Tutorial/Wikipedia links/sandbox", "Wikipedia:Tutorial/Citing sources/sandbox", "Wikipedia:Tutorial/Keep in mind/sandbox")
return True▼
def should_be_reset(box):
curtime = datetime.utcnow()
query = api.
pageid = query.keys()[0]
box_stamp = api.parse_date(query[pageid]["revisions"][0]["timestamp"])
if box_stamp < curtime -
return True
return False
def sandbox_wait(box):
for sandbox in sandboxes:
Line 158 ⟶ 157:
api.edit(sandbox, reset_text, "Clearing sandbox) (bot", True, True)
else:
Thread(target=sandbox_wait, args=(sandbox)).start()
▲ if should_be_reset(sandbox):
▲ break
▲ # After it sleeps for 9 minutes without clearing the sandbox, it will be cleared regardless.
▲ api.edit(sandbox, reset_text, "Clearing sandbox", True, True)
api.logout()▼
</source>
|