利用者:.旻/bot/tool/move.py

出典: へっぽこ実験ウィキ『八百科事典(アンサイクロペディア)』
< 利用者:.旻‎ | bot‎ | tool
移動先: 案内検索
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import requests
from data import *
from properties import *
import config

def move(_from, to, reason="", movetalk=True, movesubpages=True, noredirect=True):
	if config.Detail: print 'Now moving', _from, 'to%s'%to, '...'
	# get token
	# get token
	if config.tokens == "":
		data = request("action=query&meta=tokens")
		print data
		config.tokens = data['query']['tokens']["csrftoken"]
	
	# general
	prop = "action=move&from="+quote(_from.encode('utf8'))+"&to="+quote(to.encode('utf8'))+"&reason="+quote(reason.encode('utf8'))
	
	if movetalk: prop += "&movetalk"
	if movesubpages: prop += "&movesubpages"
	if noredirect: prop += "&noredirect"
	
	d = request(prop, data={'token':config.token})
	
	if config.Detail: print 'Done.'
	return d