Module:Sandbox/MjolnirPants
Appearance
local getArgs = require('Module:Arguments').getArgs
p = {}
function p.test(frame)
local pgCont = mw.title.new("User:MjolnirPants/Voices"):getContent()
return pgCont
end
function p.PingRFCUsers(frame)
local args = getArgs(frame)
return p._PingRFCUsers(args)
end
function p._PingRFCUsers(args)
local pageSource = ""
--check the size of the arguments array
--if there's more than one, the second one
--should be the name of the page on which
--to find the discussion
local flag = 0
if (table.getn(args) > 1) then
--get the title from the second argument
pageSource = mw.title.new(args[2]):getContent()
flag = 1
else
--If no second parameter was passed, then
--the discussion is on the current page
pageSource = mw.title.getCurrentTitle():getContent()
flag = 2
end
local users = {}
local ii = 1
local i, j = string.find(pageSource, "==" .. args[1])
pageSource = string.sub(pageSource, i + string.len(args[1]) + 4)
i, j = string.find(pageSource, "==")
pageSource = string.sub(pageSource, 1, i - 1)
i, j = string.find(pageSource, "%[%[User:")
local uName = ""
local k, l, m, n = i + 1
local cat = "Pinging participants of [[#" .. args[1] .."|previous RfC]]: {{ping"
while i ~= nil do
i, j = string.find(pageSource, "%[%[User:")
if j then
pageSource = string.sub(pageSource, j)
j = 1
k, l = string.find(pageSource, "|")
m, n = string.find(pageSource, "%]%]")
if (m > k) then
uName = string.sub(pageSource, j + 1, k - 1)
pageSource = string.sub(pageSource, k)
else
uName = string.sub(pageSource, j + 1, m - 1)
pageSource = string.sub(pageSource, m)
end
--users[ii] = uName
cat = cat .. "|" .. uName
ii = ii + 1
end
end
cat = cat .. "}} ~~~~"
-- local ret = "{{u|"
-- for _, v in ipairs(users) do
-- ret = ret .. v .. "|"
-- end
--return string.sub(ret, 1, string.len(ret) - 1) .. "}}"
--return pageSource.. "\r\nusers:" .. cat .. "\r\ni:" .. i .. " j:" .. j .. " k:" .. k .. " l:" .. l .. " m:" .. m .. " n:" .. n
--return cat
return flag
end
return p