模块

模块:RequestHelper

来自蒙纳多研究本部

Monado​(留言 | 贡献)2020年6月6日 (六) 01:39的版本 (MWBot)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:RequestHelper/doc创建

local p = {}

p.language = "cn"
-- p.entrypoint = "http://dev.xenoblade.cn:3000"
p.entrypoint = "http://172.19.82.27:3000"

local cache = {}

function p.post(tablename, row_id, language)
  if language == nil then
    language = p.language
  end

  local cacheKey = tablename .. ":" .. row_id .. ":" .. language
  if cache[cacheKey] == nil then
    cache[cacheKey] =
      mw.xbdb.post(
      p.entrypoint,
      {
        game = "xb1",
        table = tablename,
        row_id = row_id,
        language = language,
      }
    )
  end
  return cache[cacheKey]
end

return p