local p = local TwitterSnowflake = require('Module:TwitterSnowflake')local CiteWeb = require('Module:Cite web')['']
local function _if(arg) return arg and arg ~= or nilend
p.main = function(frame) frame.args = frame:getParent.args return p[''](frame)end
p[''] = function(frame) local args = frame.args local cite_args = if _if(args.last1 or args.last) then cite_args.author = (args.last1 or args.last) .. (_if(args.first1 or args.first) and (', ' .. (args.first1 or args.first)) or ) .. ' [@' .. (args.user or '') .. ']' elseif _if(args.author1 or args.author) then cite_args.author = (args.author1 or args.author) .. ' [@' .. (args.user or '') .. ']' elseif _if(args['author-link']) then cite_args.author = args['author-link'] .. ' [@' .. (args.user or '') .. ']' else cite_args.author = '@' .. (args.user or ) end if cite_args.author:find ('[Tt]witter') then cite_args.author = '((' .. cite_args.author .. '))' end if _if(tonumber(args.number)) then cite_args.date = args.date or (_if(args.number) and TwitterSnowflake.snowflakeToDate) else cite_args.date = args.date end frame.args = cite_args local output = CiteWeb(frame) frame.args = args -- Error checking local error_template = '
%s' local errors = if not (_if(args.title) or _if(args['script-title']) or args.user or args.number or args.date) then -- No title; error message is provided by CS1 module. errors[1] = ';' end if not _if(args.user) then errors[1 + #errors] = ' Missing or empty |user=;' end if not _if(args.number) then errors[1 + #errors] = ' Missing or empty |number=;' end errors[1 + #errors] = TwitterSnowflake.datecheck if errors[1] then local last = errors[#errors] errors[#errors] = last:sub(1, #last - 1) .. ' (help)' local error_out = error_template:rep(#errors):format(unpack(errors)) if mw.title.getCurrentTitle:inNamespace(0) then error_out = error_out .. '' end output = output .. error_out end return outputendreturn p