「モジュール:17live」の版間の差分
ナビゲーションに移動
検索に移動
編集の要約なし |
影響の少ないと思われる 17live , pococha で |
||
| 15行目: | 15行目: | ||
dataStore['17liveアカウント'] = t_name | dataStore['17liveアカウント'] = t_name | ||
local result = mw.smw.set | local ok, result = pcall(mw.smw.set, dataStore ) | ||
if result | if not ok then | ||
return '<span class="error">SMW Lua error: ' .. tostring(result) .. '</span>' | |||
end | |||
if result ~= true then | |||
-- error message to be found in result.error | -- error message to be found in result.error | ||
return ' | return '<span class="error">SMW set error: ' .. tostring(result.error) .. '</span>' | ||
end | end | ||
end | end | ||
2026年10月3日 (土) 16:09時点における最新版
このモジュールについての説明文ページを モジュール:17live/doc に作成できます
local p = {};
local function setProperty(t_name)
-- メイン空間のみ
if not mw.title.getCurrentTitle().namespace == 0 then
return true;
end
if not mw.smw then
return true;
end
local dataStore = {}
dataStore['17liveアカウント'] = t_name
local ok, result = pcall(mw.smw.set, dataStore )
if not ok then
return '<span class="error">SMW Lua error: ' .. tostring(result) .. '</span>'
end
if result ~= true then
-- error message to be found in result.error
return '<span class="error">SMW set error: ' .. tostring(result.error) .. '</span>'
end
end
function p.main( frame )
local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:17live', removeBlanks = false, parentFirst = true });
-- ID
local t_name = args[1] or args.id or '';
-- URL
local formatterURL = "https://17.live/profile/r/$1";
local url = mw.ustring.gsub(formatterURL, "$1", t_name);
-- 表示名
local name = args[2] or args.name or '';
-- SemanticMediaWiki
if not args.nosmw then
setProperty(t_name);
end
-- 表示名デフォルト
if name == '' then
name = "17liveアカウント";
end
local t_name2 = '(@' .. t_name ..')';
if mw.ustring.match(name, '%(' .. t_name .. '%)$') then
t_name2 = '';
end
return '[' ..url ..' ' ..name ..'] ' ..t_name2 ..' - [[17LIVE]]';
end
return p;