Module:GEBot dump
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Module:GEBot dump/doc. [edit] [history] [purge]
Module:GEBot dump loads data from Module:Exchange/< ... >.
For this module's usage, see User:Gaz GEBot § Bot details.
local p = {}
function p.get(frame)
return p._get(frame.args[1], frame.args[2]=='yes', frame.args[3] == 'yes')
end
function p._get(offset, allowhistorical, exchangehistoricalpagename)
local pgnm = 'Exchange'
if exchangehistoricalpagename then
pgnm = 'Exchange historical'
end
local dpl = [=[
{{#dpl:
|namespace=Module
|titlematch=%s/%%
|nottitlematch=%s/%%/Data
|nottitlematch=%s/%%/doc
|nottitlematch=%s/%%/annotations.json
|ordermethod=title
|format=,@%%TITLE%%@,,
|replaceintitle=/^%s\//,
|offset=%s
}}
]=]
dpl = dpl:format(pgnm,pgnm,pgnm,pgnm,pgnm,offset)
local res = mw.getCurrentFrame():preprocess(dpl)
local out = {}
for v in mw.ustring.gmatch(res, '@(.-)@') do
local data_good, data = pcall(mw.loadData, 'Module:'..pgnm..'/'..v)
if data_good then
local allowpage = true
if data.historical then
if not allowhistorical then
allowpage = false
end
end
if allowpage then
local out_data = {
id=data.itemId,
name=v,
limit=data.limit,
value=data.value,
icon=data.icon,
members=data.members,
examine=data.examine
}
local val = tonumber(data.value)
if (data.alchable == nil or data.alchable == true) and val then
local mult = 0.6
if type(data.alchmultiplier) == 'number' then
mult = data.alchmultiplier
end
out_data.highalch = math.max(1, math.floor(mult * val))
out_data.lowalch = math.max(1, math.floor(mult * val * 2/3))
end
table.insert(out, out_data)
end
end
end
return mw.text.jsonEncode(out)
end
return p