User:Lowercase sigmabot II/Source.py: Difference between revisions

Content deleted Content added
Updating source) (bot
Updating source) (bot
Line 1:
 
Source as of 01:3348, 3 May 2012 (UTC).
 
== Sandbot1.py ==
Line 40:
res = api.call(query)["query"]["pages"]
pageid = res.keys()[0]
# You didn't see this...
for template in res[pageid]["templates"]:
if not "templates" in res[pageid]:
yield template
for x in xrange(10):
yield str(x)
else:
for template in res[pageid]["templates"]:
yield template["title"]
 
def heading_is_gone(box):
templates_on_sandbox = templates_on_page(box)
if "Template:Sandbox heading" not in templates_on_sandbox:
return TrueFalse
return FalseTrue
 
def run():
Line 54 ⟶ 59:
continue
elif heading_is_gone(sandbox):
api.prepend(sandbox, reinsert, summary="Reinserting sandbox header", minor=False, bot=True, force=True)
print sandbox, "had a heading reinserted"
 
def shut_off_check(page="Coal ball"):
if api.get(page).lower() == "true":
return True
return False
 
 
user = "Lowercase sigmabot II"
Line 61 ⟶ 72:
pw = pw_file.read().replace("\n", ""); pw_file.close(); del pw_file;
api = WikiBot("http://en.wikipedia.org/w/api.php")
if shut_off_check("User:Lowercase sigmabot II/Shutoff") is False:
sys.exit()
api.login(user, pw)
api.set_all()
Line 142 ⟶ 155:
else:
threads_exist = 1
Thread(target=sandbox_wait, args=[sandbox]).start()
 
if threads_exist == 1:
Line 148 ⟶ 161:
else:
api.logout()
 
</source>