MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / getLastOnlineDays

Function getLastOnlineDays

isalive/isalive.ts:75–100  ·  view source on GitHub ↗
(user: Api.User)

Source from the content-addressed store, hash-verified

73 ) {
74 return 0;
75 }
76 if (user.status instanceof Api.UserStatusOffline) {
77 if (user.status.wasOnline) {
78 const days = Math.floor(
79 (Date.now() - Number(user.status.wasOnline) * 1000) /
80 (1000 * 60 * 60 * 24)
81 );
82 return Math.max(0, days);
83 }
84 return null;
85 }
86 if (user.status instanceof Api.UserStatusLastWeek) {
87 return 7;
88 }
89 if (user.status instanceof Api.UserStatusLastMonth) {
90 return 30;
91 }
92 return null;
93}
94
95function getLastOnlineDateTime(user: Api.User): string | null {
96 if (!user.status) return null;
97 if (user.status instanceof Api.UserStatusOnline) {
98 return "在线";
99 }
100 if (user.status instanceof Api.UserStatusRecently) {
101 return "最近上线";
102 }
103 if (user.status instanceof Api.UserStatusOffline) {

Callers 1

IsAlivePluginClass · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected