通知内容中增加流量统计, 默认不开启

This commit is contained in:
Mizore 2023-04-01 15:53:02 +08:00
parent 8faac3a374
commit 6f913a2d0f

View File

@ -275,6 +275,23 @@ local function append()
msg = msg .. "\n频段: B" .. band
end
-- 流量统计
local uplinkGB, uplinkB, downlinkGB, downlinkB = mobile.dataTraffic()
uplinkB = uplinkGB * 1024 * 1024 * 1024 + uplinkB
downlinkB = downlinkGB * 1024 * 1024 * 1024 + downlinkB
local function formatBytes(bytes)
if bytes < 1024 then
return bytes .. "B"
elseif bytes < 1024 * 1024 then
return string.format("%.2fKB", bytes / 1024)
elseif bytes < 1024 * 1024 * 1024 then
return string.format("%.2fMB", bytes / 1024 / 1024)
else
return string.format("%.2fGB", bytes / 1024 / 1024 / 1024)
end
end
-- msg = msg .. "\n流量: ↑" .. formatBytes(uplinkB) .. " ↓" .. formatBytes(downlinkB)
-- 位置
local _, _, map_link = util_location.get()
if map_link ~= "" then