https://wiki.endmyopia.org/index.php?title=Module:Reply_to&feed=atom&action=historyModule:Reply to - Revision history2024-03-28T16:51:05ZRevision history for this page on the wikiMediaWiki 1.39.3https://wiki.endmyopia.org/index.php?title=Module:Reply_to&diff=2163&oldid=prevNottNott: Created page with "local p = {} local function makeError(msg) msg ='Error in Template:Reply to: ' .. msg return mw.text.tag('strong', {['class']='error'}, msg) end function p.replyto(fra..."2020-05-24T11:59:07Z<p>Created page with "local p = {} local function makeError(msg) msg ='Error in <a href="/wiki/Template:Reply_to" title="Template:Reply to">Template:Reply to</a>: ' .. msg return mw.text.tag('strong', {['class']='error'}, msg) end function p.replyto(fra..."</p>
<p><b>New page</b></p><div>local p = {}<br />
<br />
local function makeError(msg)<br />
msg ='Error in [[Template:Reply to]]: ' .. msg<br />
return mw.text.tag('strong', {['class']='error'}, msg)<br />
end<br />
<br />
function p.replyto(frame)<br />
local origArgs = frame:getParent().args<br />
local args = {}<br />
local maxArg = 1<br />
local usernames = 0<br />
for k, v in pairs(origArgs) do<br />
if type(k) == 'number' then<br />
if mw.ustring.match(v,'%S') then<br />
if k > maxArg then maxArg = k end<br />
usernames = usernames + 1<br />
local title = mw.title.new(v)<br />
if not title then return makeError('Input contains forbidden characters.') end<br />
args[k] = title.rootText<br />
end<br />
elseif v == '' and k:sub(0,5) == 'label' then<br />
args[k] = '&#x200B;'<br />
else<br />
args[k] = v<br />
end<br />
end<br />
<br />
if usernames > (tonumber(frame.args.max) or 50) then<br />
return makeError(string.format(<br />
'More than %s names specified.',<br />
tostring(frame.args.max or 50)<br />
))<br />
else<br />
if usernames < 1 then<br />
if frame.args.example then args[1] = frame.args.example else return makeError('Username not given.') end<br />
end<br />
args['label1'] = args['label1'] or args['label']<br />
local isfirst = true<br />
local outStr = args['prefix'] or '@'<br />
for i = 1, maxArg do<br />
if args[i] then<br />
if isfirst then<br />
isfirst = false<br />
else<br />
if ( (usernames > 2) or ((usernames == 2) and (args['c'] == '')) ) then outStr = outStr..', ' end<br />
if i == maxArg then outStr = outStr..' '..(args['c'] or 'and') .. ' ' end<br />
end<br />
outStr = string.format(<br />
'%s[[User:%s|%s]]',<br />
outStr,<br />
args[i],<br />
args['label'..tostring(i)] or args[i]<br />
)<br />
end<br />
end<br />
outStr = outStr..(args['p'] or ':')<br />
return mw.text.tag('span', {['class']='template-ping'}, outStr)<br />
end<br />
end<br />
<br />
return p</div>NottNott