This module extracts all the users in either a marked LST or in wikitext and generates links reflecting a courtesy ping.
| This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome. |
| This module depends on the following other modules: |
| Description | This module extracts all the users in either a marked LST or in wikitext and generates links reflecting a courtesy ping. |
|---|---|
| Status | Alpha |
| Updated | June 25, 2026 (51 days ago) |
| Dependencies | Module:Arguments |
This module extracts all the users in either a marked LST or in wikitext and generates links reflecting a courtesy ping.
{{#invoke:discussion ping|main|}}
{{#invoke:discussion ping|main|1=[[User:Example]] [[User:Example2|Example]]}} yields @Example2 @Example
{{#invoke:discussion ping|main|title=User:Awesome Aasim/Example discussion#Some_discussion}} yields @Example2 @Example4 @Example3 @Example
{{#invoke:discussion ping|main|title=User:Awesome Aasim/Example discussion}} yields @Example4 @Example3 @Example2 @Example5 @Example
Note: For really large pages, this template or module falls apart.
discussion_ping.main( frame ) (function)frame processing frame (table)discussion_ping._main( args ) (function)Documentation above is auto generated
--- This module extracts all the users in either a marked LST or in wikitext and
-- generates links reflecting a courtesy ping.
--
-- @module discussion_ping
-- @require Module:Arguments
-- @release alpha
local p = {}
local getArgs = require("Module:Arguments").getArgs
--- Makes a user link
-- @param {table} userTitle the title for the user object
-- @return {string} the formatted user link in the form of a ping
local function makeUserLink( userTitle )
return mw.ustring.format( '@[[%s|%s]]', userTitle.prefixedText, userTitle.text )
end
--- Entry point for module
-- @param {table} frame processing frame
-- @return {string} wikitext
function p.main( frame )
local args = getArgs( frame )
return p._main( args, frame )
end
--- The main function for this module
--
-- @param {table} args processing arguments
-- @param {string} args.wikitext Wikitext to extract pings from
-- @param {string} args.title Name of title to check for pings
-- @param {string} args.section LST section
-- @return List of pings
function p._main( args, frame )
frame = frame or mw.getCurrentFrame()
if not mw.isSubsting() and not args['__demo'] then
error( "Module:Courtesy ping must be substituted", 0 )
end
local links = {}
local noPing = {}
local i = 1
while args["noping" .. i] do
noPing[ args[ "noping" .. i ] ] = true
i = i + 1
end
local wikitext = args['wikitext'] or args[1] or nil
local pageToInclude = args['title'] or ''
local sectionName = args['section'] or nil
local lstTitle = mw.title.new( pageToInclude )
if not wikitext and lstTitle then
if sectionName or ( lstTitle.fragment and lstTitle.fragment ~= '' ) then
wikitext = frame:callParserFunction('#lsth', { lstTitle.prefixedText, sectionName or lstTitle.fragment })
else
wikitext = frame:preprocess(lstTitle:getContent())
end
elseif not wikitext then
error( "Wikitext or a page title with section must be specified!", 0 )
end
-- Thanks ChatGPT
for link, display in mw.ustring.gmatch(wikitext, "%[%[([^%[%]|]+)%|?([^%[%]]*)%]%]") do
if display == "" then
display = link -- No display text, so use the link itself
end
if not links[ link ] then links[ link ] = mw.title.new( link ) end
end
local out = {}
for k,v in pairs(links) do
if v ~= nil then
if v.namespace == 2 and not v.isSubpage and not noPing[ v.text ] then
table.insert( out, makeUserLink( v ) )
end
end
end
return '<!-- Begin [[Module:Discussion ping]] -->' .. mw.text.trim( table.concat( out, ' ' ) )
.. '<!-- End [[Module:Discussion ping]] -->'
end
return p
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.