मॉड्यूल:ping user
"इस मॉड्यूल हेतु प्रलेख मॉड्यूल:ping user/doc पर बनाया जा सकता है"
local export = {}
local match = string.match
local function link(username, link_text)
if type(username) ~= "string" then
error('The function "link" requires a string argument.')
end
local namespace = match(username, "^(.+):")
local userpage
if namespace and namespace ~= "सदस्य" then
if match(username, "^%x%x?%x?%x?:%x%x?%x?%x?:%x%x?%x?%x?:%x%x?%x?%x?:%x%x?%x?%x?:%x%x?%x?%x?:%x%x?%x?%x?:%x%x?%x?%x?$") then
userpage = username
else
error('The username "' .. username .. '" contains the incorrect namespace "' .. tostring(namespace) .. '".')
end
else
userpage = match(username, ":(.+)$") or username
end
if not link_text then
link_text = userpage
end
return "[[सदस्य:" .. userpage .. "|" .. link_text .. "]]"
end
function export.reply_to(frame)
local params = {
[1] = { list = true, allow_holes = true },
["alt"] = { list = true, allow_holes = true },
["p"] = { allow_empty = true },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local usernames = args[1]
local link_text = args["alt"]
local prefix = "@"
local postfix = args.p or ":"
local namespace = mw.title.getCurrentTitle().nsText
local output = {}
if #usernames == 0 then
if namespace == "साँचा" then
usernames = { "उदाहरण~हिंदीविक्षनरी", maxindex = 1 }
else
error("Error in replyto template: Username not given.")
end
end
for i = 1, math.max(usernames.maxindex, link_text.maxindex) do
table.insert(output, link(usernames[i], link_text[i]))
end
output = prefix .. table.concat(output, ", ") .. postfix
return output
end
function export.ping(frame)
local params = {
[1] = { list = true, allow_holes = true },
["alt"] = { list = true, allow_holes = true },
["p"] = { allow_empty = true },
["@"] = { allow_empty = true },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local usernames = args[1]
local link_text = args["alt"]
local prefix = args["@"] or "@"
local postfix = args.p
local namespace = mw.title.getCurrentTitle().nsText
local output = {}
if #usernames == 0 then
if namespace == "साँचा" then
usernames = { "उदाहरण~हिंदीविक्षनरी", maxindex = 1 }
else
error("Error in replyto template: Username not given.")
end
end
for i = 1, math.max(usernames.maxindex, link_text.maxindex) do
table.insert(output, link(usernames[i], link_text[i]))
end
output = prefix .. table.concat(output, ", ")
return output
end
function export.link(frame)
local params = {
[1] = { list = true, allow_holes = true },
["alt"] = { list = true, allow_holes = true },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local usernames = args[1]
local link_text = args["alt"]
local namespace = mw.title.getCurrentTitle().nsText
local output = {}
if #usernames == 0 then
if namespace == "साँचा" then
usernames = { "उदाहरण~हिंदीविक्षनरी", maxindex = 1 }
else
error("Error in replyto template: Username not given.")
end
end
for i = 1, math.max(usernames.maxindex, link_text.maxindex) do
table.insert(output, link(usernames[i], link_text[i]))
end
output = table.concat(output, ", ")
return output
end
return export