Jump to content

Module:Sandbox/KEmel49

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by KEmel49 (talk | contribs) at 18:36, 4 July 2025 (test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.greet(frame)
	local name = frame.args.name or frame.args[1] or ""
	if name == "" then
		return '<strong class="error">Unable to fetch any username</strong>'
	end

	local title = mw.title.new('User:'.. name)
	if title and title.exists then
		return 'Hello [[User:'..name..'|'..name..']]'
	else
		return '<strong class="error">Userpage does not exist or user is not registered</strong>'
	end
end

function p.hello(frame)
	if frame.args[1] == nil then
		return "[[Module:Sandbox/KEmel49]]"
	elseif frame.args[1] then
		return '[[Module:'..frame.args[1]..'|'..frame.args[1]..']]'
    end
end

function p.sign(frame)
	return frame:preprocess('~~~~')
end

function p.notify(frame)
	local args = frame.args
	local article = args.article or ""
	local diff = args.diff or ""
	local cite_format = args["cite_format"] or ""
	local ogurl = args.ogurl or ""
	local username = mw.title.getCurrentTitle().text

	local out = {}

	table.insert(out, "== Re: " .. article .. " ==\n\n")

	table.insert(out, '[[File:Information.svg|20px]] Hello ' .. username .. ', This is to let you know that ')
	if diff ~= "" then
		table.insert(out, '[[Special:Diff/' .. diff .. '|one of your recent edits]]')
	else
		table.insert(out, 'one of your recent edits')
	end

	table.insert(out, ' at \'\'[[' .. article .. ']]\'\' caused a citation error. ')

	if cite_format ~= "" then
		table.insert(out, 'you have added invalid url at {{Tl|' .. cite_format .. '}} template. ')
	end

	if ogurl ~= "" then
		table.insert(out, 'Your url input was <code>' .. mw.text.nowiki(ogurl) .. '</code>. ')
	end

	table.insert(out, 'Do not add invalid URLs and use preview before saving your edit. Happy editing.')

	table.insert(out, ' <!-- User:KEmel49/sandbox 5 -->')

	return table.concat(out)
end

return p