Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Bot task
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local p = {} function p.main(frame) local args = getArgs(frame) return p._main(args) end local function error(text) 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 return true end end 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 function p._main(args) -- check for invalid parameters for param, value in pairs(args) do if not has_value({'bot','task','min_edits','duration','title_regex','title','namespace','action','summary','summary_regex','notify'}, param) then return error('unknown parameter: ' .. param .. ' used') end end if not args.bot or not args.task then return error('required parameters "bot" and/or "task" missing') end -- set defaults if not given args.min_edits = args.min_edits or 1 args.duration = args.duration or '3 days' args.action = args.action or 'edit' local str = string.format("* [[User:%s|%s]]: %s. '''Frequency''': β₯ %s %s%s in the last %s. ", 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 ) if args.title_regex then str = str .. string.format("'''Pages''': matching <code>%s</code> %s", args.title_regex, args.namespace and string.format("in namespace: %s.", get_namespaces(args.namespace)) or '') 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.namespace then str = str .. string.format("In namespace: %s. ", get_namespaces(args.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 args.notify then local alertpage = mw.title.new(args.notify, 3).fullText str = str .. string.format("<b>Will notify</b> [[%s|%s]] in case of issues. ", alertpage, args.notify) end return str end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Bot task/doc
(
edit
)