모듈:WikidataCheck

포장 (토론 | 기여)님의 2019년 12월 6일 (금) 19:13 판 (새 문서: local p = {} function p.wikidatacheck(frame) local pframe = frame:getParent() local config = frame.args -- the arguments passed BY the template, in the wikitext of the templa...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

local p = {}

function p.wikidatacheck(frame) local pframe = frame:getParent()local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itselflocal args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the templatelocal property = config.propertylocal value = config.value or ""local catbase = config.categorylocal namespaces = config.namespaceslocal ok = false -- one-way flag to check if we're in a good namespacelocal ns = mw.title.getCurrentTitle().namespacefor v in mw.text.gsplit( namespaces, ",", true) doif tonumber(v) == ns thenok = true end endif not ok then -- not in one of the approved namespacesreturn "" endlocal entity = mw.wikibase.getEntityObject()if not entity then -- no Wikidata itemreturn "" endlocal claims = entity.claims or {}local hasProp = claims[property]if not hasProp then -- no claim of that propertyreturn "" -- bad. Bot needs to add the property endlocal propValue = hasProp[1].mainsnak.datavalue.value -- This should eventually iterate over all possible values?if value == "" thenreturn nil -- Using Wikidata elseif propValue == value thenreturn "" -- yay! elsereturn "" -- needs human review :( end end

return p