Module:Sock list

local p = {} local getArgs = require('Module:Arguments').getArgs

function p.main(frame) local args = getArgs(frame) return p._main(frame, args) end

function isIpOrRange(s) local modip = require('Module:IP') local success, ip = pcall(modip.IPAddress.new, s)   if success then return 'ip' end success, ip = pcall(modip.Subnet.new, s)   if success then return 'range' end return nil end

function listEntry(frame, sock, master) local template = isIpOrRange(sock) and "checkip" or "checkuser" local li = mw.html.create('li') li:wikitext(frame:expandTemplate{title=template, args={sock, ['master name']=master}}) return li end

function toolEIA(args) local url = "https://tools.wmflabs.org/sigma/editorinteract.py?users=" .. mw.uri.encode(args.master) for i, sock in ipairs(args) do url = url .. "&users=" .. mw.uri.encode(sock) end return "[" .. url .. " Editor interaction utility]" end

function toolTimeline(args) local url = "https://tools.wmflabs.org/interaction-timeline?wiki=enwiki&user=" .. mw.uri.encode(args.master) .. "&user=" .. mw.uri.encode(args[1]) return "[" .. url .. " Interaction Timeline]" end

function toolCompare(args) local url = "https://tools.wmflabs.org/betacommand-dev/UserCompare/" .. mw.uri.encode(args.master) return "[" .. url .. " User compare report]" end

function p._main(frame, args) local socklist = mw.html.create('ul') if args[1] then for i, sock in ipairs(args) do			socklist:node(listEntry(frame, sock, args.master)) end end local tools = mw.html.create('li') tools :attr('class', 'plainlinks') :wikitext("Tools: ") :node(toolEIA(args)) :wikitext(" • ") :node(toolTimeline(args)) :wikitext(" • ") :node(toolCompare(args)) :wikitext(" Auto-generated every hour. ") socklist:node(tools) return socklist end

return p