From 6f913a2d0f0738a61678b5942bed04af066dc528 Mon Sep 17 00:00:00 2001 From: Mizore Date: Sat, 1 Apr 2023 15:53:02 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E9=80=9A=E7=9F=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E4=B8=AD=E5=A2=9E=E5=8A=A0=E6=B5=81=E9=87=8F=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1,=20=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/util_notify.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/script/util_notify.lua b/script/util_notify.lua index 863d588..abe5a99 100644 --- a/script/util_notify.lua +++ b/script/util_notify.lua @@ -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