Module:Checkuser/sandbox: Difference between revisions
Appearance
Content deleted Content added
init from Module:Checkuser; see that history for attribution |
fix better handling of ip ranges |
||
Line 145: | Line 145: | ||
) |
) |
||
end |
end |
||
local slash = string.find(ip, '/') |
|||
local actualip = ip |
|||
if slash ~= nil then |
|||
actualip = string.sub(ip, 0, slash) |
|||
end |
|||
local span = mw.html.create('span'):attr('class', 'plainlinks neverexpand cuEntry') |
local span = mw.html.create('span'):attr('class', 'plainlinks neverexpand cuEntry') |
||
local curtitle = mw.title.getCurrentTitle() |
local curtitle = mw.title.getCurrentTitle() |
||
local links = { |
local links = { |
||
'[[User talk:' .. |
'[[User talk:' .. atualip .. '|talk]]' .. |
||
'<sup><span style="font-size: 120%;">' .. |
'<sup><span style="font-size: 120%;">' .. |
||
link('User talk:' .. |
link('User talk:' .. actualip, { |
||
action = 'edit', |
action = 'edit', |
||
section = 'new' |
section = 'new' |
||
}, '<span style="color: grey">+</span>') .. |
}, '<span style="color: grey">+</span>') .. |
||
'</span></sup>', |
'</span></sup>', |
||
link('User:' .. ip, { |
|||
action = 'edit', |
|||
preload = 'Template:Checkip/Preload', |
|||
['preloadparams[]'] = ( |
|||
mastername and |
|||
mastername or |
|||
'<!-- Insert sock master name here -->' |
|||
) |
|||
}, 'tag'), |
|||
'[[Special:Contributions/' .. ip .. '|contribs]]', |
'[[Special:Contributions/' .. ip .. '|contribs]]', |
||
link('Special:AbuseLog', { |
link('Special:AbuseLog', { |
||
wpSearchUser = ip |
wpSearchUser = actualip -- no support for searching ip range in abuse log yet |
||
}, 'filter log'), |
}, 'filter log'), |
||
extlink( |
extlink( |
||
tostring(mw.uri.new('https://whois-referral.toolforge.org/gateway.py'):extend({ |
tostring(mw.uri.new('https://whois-referral.toolforge.org/gateway.py'):extend({ |
||
lookup = 'true', |
lookup = 'true', |
||
ip = |
ip = actualip |
||
})), |
})), |
||
'WHOIS' |
'WHOIS' |
||
), |
), |
||
extlink( |
extlink( |
||
tostring(mw.uri.new('https://www.robtex.com/rbls/' .. |
tostring(mw.uri.new('https://www.robtex.com/rbls/' .. actualip .. '.html')), |
||
'RBLs' |
'RBLs' |
||
), |
), |
||
extlink( |
extlink( |
||
tostring(mw.uri.new('https://ipcheck.toolforge.org/index.php'):extend({ |
tostring(mw.uri.new('https://ipcheck.toolforge.org/index.php'):extend({ |
||
ip = |
ip = actualip |
||
})), |
})), |
||
'proxy check' |
'proxy check' |
||
Line 203: | Line 201: | ||
'</span>', |
'</span>', |
||
link('Special:Log/block', { |
link('Special:Log/block', { |
||
page = 'User:' .. ip |
page = 'User:' .. actualip -- no support for ip range in block log yet |
||
}, 'block log'), |
}, 'block log'), |
||
extlink( |
extlink( |
Revision as of 04:41, 25 June 2025
![]() | This is the module sandbox page for Module:Checkuser (diff). |
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module depends on the following other modules: |
local p = {}
local getArgs = function(fr)
return require('Module:Arguments').getArgs(fr, {
trim = true,
removeBlanks = true
})
end
local noping = function(name)
return require('Module:No ping')._main({name})
end
local middot = ' <b>·</b> '
local spi = 'Wikipedia:Sockpuppet investigations'
local extlink = function(url, text)
return '[' .. tostring(url) .. (text and ' ' .. text or '') .. ']'
end
local link = function(page, param, text)
return extlink(mw.uri.fullUrl(page, param), text)
end
function p.user(frame)
local args = getArgs(frame)
return p._user(args['User'] or args[1], args['master name'], args['master'])
end
function p._user(sock, mastername, master)
if not sock then
return (
'<strong class="error">No username provided.</strong>' ..
'[[Category:Checkuser with no specified user]]'
)
end
local span = mw.html.create('span'):attr('class', 'plainlinks cuEntry')
local curtitle = mw.title.getCurrentTitle()
local links = {
'[[User talk:' .. sock .. '|talk]]' ..
'<sup><span style="font-size: 120%;">' ..
link('User talk:' .. sock, {
action = 'edit',
section = 'new'
}, '<span style="color: grey;">+</span>') ..
'</span></sup>',
link('User:' .. sock, (function()
local param = {
action = 'edit',
preload = 'Template:Checkuser/Preload' .. (master == 'yes' and ' master' or '')
}
if master ~= 'yes' then
param['preloadparams[]'] = (
mastername and
mastername or
'<!-- insert sock master here -->'
)
end
return param
end)(), 'tag'),
'[[Special:Contributions/' .. sock .. '|contribs]]' ..
'<span class="sysop-show">',
'[[Special:DeletedContributions/' .. sock .. '|deleted contribs]]' ..
'</span>',
link('Special:Log', {
user = sock
}, 'logs'),
link('Special:AbuseLog', {
wpSearchUser = sock
}, 'filter log') ..
'<span class="sysop-show">',
'[[Special:Block/' .. sock .. '|block user]]' ..
(function()
if curtitle:isSubpageOf(mw.title.new(spi)) then
return (
middot .. link('Special:Block', {
wpBlockAddress = sock,
wpExpiry = 'indefinite',
wpReason = 'Abusing [[WP:Sock puppetry|multiple accounts]]',
['wpReason-other'] = 'Please see: [[:w:en:' .. spi .. '/' ..
mw.text.split(curtitle.text, '/')[2] ..
']]'
}, 'spi block')
)
else
return ''
end
end)() ..
'</span>',
link('Special:Log/block', {
page = 'User:' .. sock
}, 'block log'),
'[[:m:Special:CentralAuth/' .. sock .. '|CA]]' ..
'<span class="cuLink checkuser-show">',
link('Special:CheckUser', (function()
local param = {
user = sock
}
if mw.text.split(curtitle.prefixedText, '/')[1] == spi then
param['reason'] = sock .. ' from [[' .. curtitle.prefixedText .. ']]'
end
return param
end)(), 'CheckUser') ..
'(' .. link('Special:CheckUserLog', {
cuSearch = sock
}, 'log') .. ')',
link('Special:Investigate', (function()
local param = {
targets = sock
}
if curtitle.prefixedText == spi .. '/' .. table.concat({
mw.text.split(curtitle.prefixedText, '/')[2],
mw.text.split(curtitle.prefixedText, '/')[3]
}, '/') then
param['reason'] = sock .. ' from [[' .. curtitle.prefixedText .. ']]'
end
return param
end)(), 'investigate'),
extlink(
tostring(mw.uri.new('https://checkuser.wikimedia.org/w/index.php'):extend({
title = 'Special:Search',
search = sock,
ns0 = 1,
ns2 = 1,
ns14 = 1
})),
'cuwiki'
) ..
'</span>'
}
span = span:wikitext(table.concat({
noping(sock),
'(' .. table.concat(links, middot) .. ')'
}, ' '))
return tostring(span) .. '__NOINDEX__'
end
function p.ip(frame)
local args = getArgs(frame)
return p._ip(args['User'] or args[1], args['master name'])
end
function p._ip(ip, mastername)
if not ip then
return (
'<strong class="error">No username provided.</strong>' ..
'[[Category:Checkip with no specified IP]]'
)
end
local slash = string.find(ip, '/')
local actualip = ip
if slash ~= nil then
actualip = string.sub(ip, 0, slash)
end
local span = mw.html.create('span'):attr('class', 'plainlinks neverexpand cuEntry')
local curtitle = mw.title.getCurrentTitle()
local links = {
'[[User talk:' .. atualip .. '|talk]]' ..
'<sup><span style="font-size: 120%;">' ..
link('User talk:' .. actualip, {
action = 'edit',
section = 'new'
}, '<span style="color: grey">+</span>') ..
'</span></sup>',
'[[Special:Contributions/' .. ip .. '|contribs]]',
link('Special:AbuseLog', {
wpSearchUser = actualip -- no support for searching ip range in abuse log yet
}, 'filter log'),
extlink(
tostring(mw.uri.new('https://whois-referral.toolforge.org/gateway.py'):extend({
lookup = 'true',
ip = actualip
})),
'WHOIS'
),
extlink(
tostring(mw.uri.new('https://www.robtex.com/rbls/' .. actualip .. '.html')),
'RBLs'
),
extlink(
tostring(mw.uri.new('https://ipcheck.toolforge.org/index.php'):extend({
ip = actualip
})),
'proxy check'
) ..
'<span class="sysop-show">',
'[[Special:Block/' .. ip .. '|block user]]' .. (function()
if curtitle:isSubpageOf(mw.title.new(spi)) then
return (
middot .. link('Special:Block', {
wpTarget = ip,
wpReason = 'Abusing [[WP:Sock puppetry|multiple accounts]]',
['wpReason-other'] = 'Please see: [[:w:en:' .. spi .. '/' ..
mw.text.split(curtitle.text, '/')[2] ..
']]'
}, 'spi block')
)
else
return ''
end
end)() ..
'</span>',
link('Special:Log/block', {
page = 'User:' .. actualip -- no support for ip range in block log yet
}, 'block log'),
extlink(
tostring(mw.uri.new('https://guc.toolforge.org/'):extend({
by = 'date',
user = ip
})),
'cross-wiki contribs'
) ..
'<span class="cuLink checkuser-show">',
link('Special:CheckUser', (function()
local param = {
ip = ip
}
if curtitle.prefixedText == spi .. '/' .. table.concat({
mw.text.split(curtitle.prefixedText, '/')[2],
mw.text.split(curtitle.prefixedText, '/')[3]
}, '/') then
param['reason'] = '[[' .. curtitle.prefixedText .. ']]'
end
return param
end)(), 'CheckUser') .. ' ' ..
'(' .. link('Special:CheckUserLog', {
cuSearch = ip
}, 'log') .. ')' ..
'</span>'
}
span = span:wikitext(table.concat({
noping(ip),
'(' .. table.concat(links, middot) .. ')'
}, ' '))
return tostring(span)
end
return p