Content deleted Content added
No edit summary |
fix |
||
(20 intermediate revisions by the same user not shown) | |||
Line 8:
end
local function
return '*' .. require('Module:Error').error{ 'Invalid task config: ' .. text, tag = 'p' }
end
local function has_value(array, val)
for index, value in ipairs(array) do
if value == val then
Line 16 ⟶ 20:
return false
end
local function lowerfirst(s)
return s:sub(1,1):lower()..s:sub(2)
end
local function get_namespaces(namespaces_list)
local list = {}
for token in string.gmatch(namespaces_list, "%d+") do
local ns_id = tonumber(token)
table.insert(list, ns_id ~= 0 and lowerfirst(mw.site.namespaces[ns_id]['name']) or 'main')
end
return table.concat(list, ', ')
end
Line 22 ⟶ 39:
-- check for invalid parameters
for param, value in pairs(args) do
if not has_value({'bot','task','min_edits','duration','title_regex','title','
return error('
end
end
if not args.bot or not args.task then
return error('
end
-- set defaults if not given
args.min_edits = args.min_edits or 1
args.duration = args.duration or '
args.action = args.action or 'edit'
local str = string.format("* [[User:%s|%s]]: %s. '''Frequency''':
args.bot, args.bot,
args.task,
args.min_edits,
args.action == 'edit' and 'edit' or args.action .. ' action',
args.min_edits == 1 and '' or 's',
args.duration
Line 44 ⟶ 63:
if args.title_regex then
str = str .. string.format("'''Pages''': matching <code>%s</code> %s", args.title_regex,
args. if args.title then
return error('do not use both title_regex and title parameters')
end
elseif args.title then
str = str .. string.format("'''Page''': [[%s]] ", args.title)
elseif args.
str = str .. string.format("In namespace
end
if args.summary_regex then
str = str .. string.format("With summary matching <code>%s</code>. ", args.summary_regex)
if args.summary then
return error('do not use both summary_regex and summary parameters')
end
elseif args.summary then
str = str .. string.format("With summary <code>%s</code>. ", args.summary)
end
if
local alertpage = mw.title.new(args.notify, 3).fullText
str = str .. string.format("Type of action: %s ", args.action)▼
str = str .. string.format("<b>Will notify</b> [[%s|%s]] in case of issues. ", alertpage, args.notify)
end
if args.email then
if string.find(args.email, '@') then
▲ str = str .. string.format("
else
local userPage = mw.title.new(args.email, 2).fullText
str = str .. string.format("<b>Will notify</b> [[%s|%s]] by email in case of issues. ", userPage, args.email)
end
end
return str
end
|