73
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
|
4 local to_string = Luan.to_string or error()
|
|
5 local Time = require "luan:Time.luan"
|
|
6 local time_now = Time.now or error()
|
|
7 local Thread = require "luan:Thread.luan"
|
|
8 local User = require "site:/lib/User.luan"
|
|
9
|
|
10
|
|
11 local Online = {}
|
|
12
|
|
13 local glob = Thread.global_map("online")
|
|
14
|
|
15 function Online.set(user)
|
|
16 glob[user.id] = time_now()
|
|
17 end
|
|
18
|
|
19 function Online.get(user)
|
|
20 local online = {}
|
|
21 local ids = user.chatting_with_ids()
|
|
22 ids[#ids+1] = user.id
|
|
23 for _, user_id in ipairs(ids) do
|
|
24 online[to_string(user_id)] = glob[user_id]
|
|
25 end
|
|
26 return online
|
|
27 end
|
|
28
|
|
29 return Online
|