Module:Sandbox/MjolnirPants
Appearance
local getArgs = require('Module:Arguments').getArgs
p = {}
function p.test(frame)
--return mw.title.getCurrentTitle():getContent()
local args = getArgs(frame)
local foo = "foobarbizban"
local i, j = string.find(foo, "bar")
local ret = "i:" .. i .. " j:" .. j
i, j = string.find(foo, "chocolate")
ret = ret .. " i2:" .. i " j2:" .. j
return ret
end
function p.PingRFCUsers(frame)
local args = getArgs(frame)
return p._PingRFCUsers(args)
end
function p._PingRFCUsers(args)
local pageSource = mw.title.getCurrentTitle():getContent()
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
end
return p