Implement guessing of email verified date #8

Merged
9382 merged 1 commits from main into main 2023-04-14 21:43:15 +00:00
2 changed files with 55 additions and 1 deletions

View File

@ -40,6 +40,47 @@ BadgesToName = {
local function round(x,n) local function round(x,n)
return string.format('%.'..(n or 0)..'f',x) return string.format('%.'..(n or 0)..'f',x)
end end
local function FromYMD(ymd)
return date.fromISO(ymd.."T00:00:00")[1]
end
local function leftpad(s,n,p)
return string.rep(p,n-#tostring(s))..s
end
local function ToYMD(seconds)
return "<t:"..seconds..":R>"
end
local IDToDate = { --Terrible ranges but it's all we have
-- {1000000000, FromYMD("2006-01-01")}, --I guess?
-- {1864564055, FromYMD("2008-08-04")},
{3800920136, FromYMD("2016-04-16")},
{9855616205, FromYMD("2017-04-02")},
{30361018662, FromYMD("2018-11-14")},
{32665806459, FromYMD("2019-01-07")},
{34758058773, FromYMD("2019-02-24")},
{65918261258, FromYMD("2020-06-05")},
{171994717435, FromYMD("2023-03-24")},
{173210319088, FromYMD("2023-04-14")}
}
--We assume linear interpolation since anything more complex I can't process
local function linterp(i1, i2, m)
return math.floor(i1 + (i2-i1)*m)
end
local function GuessDateFromAssetID(AssetID)
for i = #IDToDate, 1, -1 do --Newest to oldest
local ID,Time = unpack(IDToDate[i])
if ID < AssetID then
if not IDToDate[i+1] then
return "After "..ToYMD(Time)
end
local ParentID, ParentTime = unpack(IDToDate[i+1])
return "Around "..ToYMD(linterp(Time, ParentTime, (AssetID-ID)/(ParentID-ID)))
end
end
return "Before "..ToYMD(IDToDate[1][2])
end
discordia.extensions() discordia.extensions()
commands:Add('user',{},'user <username|mention|"me">', function(t) commands:Add('user',{},'user <username|mention|"me">', function(t)
local args=t.args local args=t.args
@ -65,6 +106,12 @@ commands:Add('user',{},'user <username|mention|"me">', function(t)
if onlineStatus_info.userPresenceType==2 then LastLocation="Ingame" end if onlineStatus_info.userPresenceType==2 then LastLocation="Ingame" end
local LastOnline = date.fromISO(onlineStatus_info.lastOnline):toSeconds()+(3600*5) local LastOnline = date.fromISO(onlineStatus_info.lastOnline):toSeconds()+(3600*5)
local verificationAssetId = API:GetVerificationItemID(id)
local verificationDate = "Not verified"
if verificationAssetId.data[1] then
verificationDate = GuessDateFromAssetID(verificationAssetId.data[1].instanceId)
end
local badgeRequest = API:GetBadgesAwardedDates(id,Badges) local badgeRequest = API:GetBadgesAwardedDates(id,Badges)
local badgeData = badgeRequest.data local badgeData = badgeRequest.data
@ -92,6 +139,7 @@ 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='Verified Email',value=verificationDate,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},

View File

@ -9,8 +9,8 @@ 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_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_INVENTORY_API = 'https://inventory.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'
local ROBLOX_SENS_DB = 'http://oef.ddns.net:9017/rbhop/sens/'
local RANK_CONSTANT_A, RANK_CONSTANT_B, RANK_CONSTANT_C, RANK_CONSTANT_D, RANK_CONSTANT_E = 0.215, 0.595, 0.215, 0.215, 0.71 local RANK_CONSTANT_A, RANK_CONSTANT_B, RANK_CONSTANT_C, RANK_CONSTANT_D, RANK_CONSTANT_E = 0.215, 0.595, 0.215, 0.215, 0.71
@ -294,6 +294,12 @@ function API:GetBadgesAwardedDates(USER_ID,BADGE_LIST)
return response,headers return response,headers
end end
function API:GetVerificationItemID(USER_ID)
if not USER_ID then return 'empty id' end
local response,headers = http_request('GET', ROBLOX_INVENTORY_API..'users/'..USER_ID.."/items/Asset/102611803", API_HEADER)
return response,headers
end
function API:GetUserThumbnail(USER_ID,TYPE,SIZE) -- https://thumbnails.roblox.com/v1/users/avatar?userIds=1455906620&size=180x180&format=Png&isCircular=false function API:GetUserThumbnail(USER_ID,TYPE,SIZE) -- https://thumbnails.roblox.com/v1/users/avatar?userIds=1455906620&size=180x180&format=Png&isCircular=false
if not USER_ID then return 'empty id' end if not USER_ID then return 'empty id' end
local _TYPE = self.ROBLOX_THUMBNAIL_TYPES[TYPE] or 'avatar' local _TYPE = self.ROBLOX_THUMBNAIL_TYPES[TYPE] or 'avatar'