Fix "Last Online" status grabbing

This commit is contained in:
Aidan 2023-03-13 16:24:30 +00:00
parent 67051b99da
commit a1470e562b
Signed by: 9382
GPG Key ID: 9BF9CD918201F681
2 changed files with 16 additions and 11 deletions

View File

@ -58,12 +58,13 @@ commands:Add('user',{},'user <username|mention|"me">', function(t)
local name = user_info.name local name = user_info.name
local displayName = user_info.displayName local displayName = user_info.displayName
-- local onlineStatus_info = API:GetUserOnlineStatus(id) local onlineStatus_info = API:GetUserOnlineStatus(id)
table.foreach(onlineStatus_info,print)
-- local LastLocation = onlineStatus_info.LastLocation
-- table.foreach(onlineStatus_info.errors[1],print) local LastLocation = onlineStatus_info.lastLocation
-- local LastOnline = date.fromISO(onlineStatus_info.LastOnline):toSeconds()+(3600*5) if onlineStatus_info.userPresenceType==2 then LastLocation="Ingame" end
local LastOnline = date.fromISO(onlineStatus_info.lastOnline):toSeconds()+(3600*5)
local badgeRequest = API:GetBadgesAwardedDates(id,Badges) local badgeRequest = API:GetBadgesAwardedDates(id,Badges)
local badgeData = badgeRequest.data local badgeData = badgeRequest.data
@ -91,8 +92,8 @@ commands:Add('user',{},'user <username|mention|"me">', function(t)
{name='ID',value=id,inline=true}, {name='ID',value=id,inline=true},
{name='Account Age',value=accountAge..' days',inline=true}, {name='Account Age',value=accountAge..' days',inline=true},
{name='Created',value='<t:'..round(created)..':R>',inline=true}, {name='Created',value='<t:'..round(created)..':R>',inline=true},
-- {name='Last Online',value='<t:'..round(LastOnline)..':R>',inline=true}, {name='Last Online',value='<t:'..round(LastOnline)..':R>',inline=true},
-- {name='Last Location',value=LastLocation,inline=true}, {name='Last Location',value=LastLocation,inline=true},
{name='Banned',value=isBanned,inline=true}, {name='Banned',value=isBanned,inline=true},
{name='Description',value=description,inline=false}, {name='Description',value=description,inline=false},
} }

View File

@ -7,6 +7,7 @@ local FIVEMAN_API_URL = 'https://api.fiveman1.net/v1/'
local ROBLOX_API_URL = 'https://users.roblox.com/v1/' local ROBLOX_API_URL = 'https://users.roblox.com/v1/'
local ROBLOX_API_URL2 = 'https://api.roblox.com/' local ROBLOX_API_URL2 = 'https://api.roblox.com/'
local ROBLOX_BADGES_API = 'https://badges.roblox.com/v1/' local ROBLOX_BADGES_API = 'https://badges.roblox.com/v1/'
local ROBLOX_PRESENCE_URL = 'https://presence.roblox.com/v1/'
local ROBLOX_THUMBNAIL_URL = 'https://thumbnails.roblox.com/v1/' local ROBLOX_THUMBNAIL_URL = 'https://thumbnails.roblox.com/v1/'
local ROBLOX_GROUPS_ROLES_URL = 'https://groups.roblox.com/v2/users/%s/groups/roles' local ROBLOX_GROUPS_ROLES_URL = 'https://groups.roblox.com/v2/users/%s/groups/roles'
@ -91,6 +92,7 @@ function formatTime(time) -- chatgpt THIS IS FOR SECONDS! NOT MILLISECONDS
return string.format("%02d:%02d.%03d", minutes, seconds, milliseconds) return string.format("%02d:%02d.%03d", minutes, seconds, milliseconds)
end end
end end
function L1Copy(t,b) b=b or {} for x,y in next,t do b[x]=y end return b end
-- [[ STRAFESNET API ]] -- -- [[ STRAFESNET API ]] --
@ -274,10 +276,12 @@ function API:GetRobloxInfoFromDiscordId(DISCORD_ID)
return response2 return response2
end end
function API:GetUserOnlineStatus(USER_ID) -- https://api.roblox.com/users/1455906620/onlinestatus function API:GetUserOnlineStatus(USER_ID)
if not USER_ID then return 'empty id' end if not USER_ID then return 'empty id' end
local response,headers = http_request('GET', ROBLOX_API_URL2..'users/'..USER_ID..'/onlinestatus', API_HEADER) local response1 = http_request('POST', ROBLOX_PRESENCE_URL..'presence/users', API_HEADER, {userIds={USER_ID}}).userPresences[1] --For LastLocation
return response,headers local response2 = http_request('POST', ROBLOX_PRESENCE_URL..'presence/last-online', API_HEADER, {userIds={USER_ID}}).lastOnlineTimestamps[1] --For a more accurate LastOnline
L1Copy(response2, response1)
return response1
end end
function API:GetBadgesAwardedDates(USER_ID,BADGE_LIST) function API:GetBadgesAwardedDates(USER_ID,BADGE_LIST)