Mercurial Hosting > chat
view src/lib/Online.luan @ 80:cb2808b8b1ad
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 10 Mar 2025 21:54:46 -0600 |
parents | a63faf49e1d7 |
children | 7b339b1ccd11 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local ipairs = Luan.ipairs or error() local to_string = Luan.to_string or error() local Time = require "luan:Time.luan" local time_now = Time.now or error() local Thread = require "luan:Thread.luan" local User = require "site:/lib/User.luan" local Online = {} local glob = Thread.global_map("online") function Online.set(user) glob[user.id] = time_now() end function Online.get(user) local online = {} local ids = user.chatting_with_ids() ids[#ids+1] = user.id for _, user_id in ipairs(ids) do online[to_string(user_id)] = glob[user_id] end return online end return Online