Module:Sandbox/pppery/massrm

Revision as of 04:57, 15 November 2022 by imported>Pppery
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/pppery/massrm/doc

local p = {};
local redr = require("Module:Redirect");
function p.main(frame)
	local args = {}
	local text = frame.args.text .. '\n';
	local matcher = mw.ustring.gmatch(text, "([^	\n]+)[	\n]+");
	local cnt = 1;
	while true do
		local p = matcher();
		if not p then
			if frame.args.go then
				return mw.dumpObject(args)
			end
			args.reason = frame.args.reason;
			frame = frame:newChild{title=frame.title, args=args};
			frame = frame:newChild{title=frame.title, args=args};
			return require("Module:Requested move").main(frame);
		end
		p = mw.ustring.gsub(p,"_"," ")
		local new = mw.ustring.gsub(p, "%(.-%)","");
		if new ~= p then
			local t = mw.title.new(p)
			if t.exists and not t.isRedirect then
				args["current" .. cnt] = p;
				args["new" .. cnt] = new
				cnt = cnt + 1
			end
		end
	end
end
return p