Module:Bot task
Appearance
Usage
Used in template Wikipedia:Bot activity monitor/config/task.
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
local parameters = {'bot', 'task', 'action', 'namespaces', 'title', 'title_regex',
'summary', 'summary_regex', 'min_edits', 'duration', 'alert_page', 'alert_mode',
'email_user', 'ping_user'
}
local function has_value (array, val)
for index, value in ipairs(array) do
if value == val then
return true
end
end
return false
end
function p._main(args)
-- set defaults if not given
args.min_edits = args.min_edits or 1
args.duration = args.duration or '1 day'
local str = string.format("* [[User:%s|%s]]: %s. '''Frequency''': minimum %s action%s in the last %s. ",
args.bot, args.bot,
args.task,
args.min_edits,
args.min_edits == 1 and '' or 's',
args.duration
)
if args.title_regex then
str = str .. string.format("'''Pages''': matching <code>%s</code> %s", args.title_regex, args.namespaces and "in namespace(s) " .. args.namespaces)
elseif args.title then
str = str .. string.format("'''Page''' [[%s]] ", args.title)
end
if (args.action ~= nil and args.action ~= 'edit') then
str = str .. string.format('Type of action: %s', args.action)
end
for param, value in pairs(args) do
if has_value(parameters, param) then
if not has_value({'bot','task','min_edits','duration','title_regex','title','namespaces'}, param) then
str = str .. param .. ': ' .. value .. ', '
end
else
str = '<span class=error>Unknown paramter: ' .. param .. ' used</span>'
end
end
return str
end
return p