2024-01-21 20:04:08 +00:00
|
|
|
open! Import
|
|
|
|
include Router_types
|
|
|
|
|
|
|
|
type t = user
|
|
|
|
|
2024-01-23 18:13:41 +00:00
|
|
|
let make nick ~userinfo ~outbox =
|
2024-01-21 20:04:08 +00:00
|
|
|
{
|
|
|
|
outbox;
|
|
|
|
userinfo;
|
2024-01-23 18:13:41 +00:00
|
|
|
nick;
|
|
|
|
nick_key = string_ci nick;
|
2024-01-21 20:04:08 +00:00
|
|
|
user_mode = Irc.Mode.Set.empty;
|
2024-01-31 02:30:54 +00:00
|
|
|
away = None;
|
2024-01-21 20:04:08 +00:00
|
|
|
membership = Dllist.create ();
|
|
|
|
}
|
|
|
|
|
|
|
|
let outbox t = t.outbox
|
|
|
|
let nick t = t.nick
|
|
|
|
let mode t = t.user_mode
|
|
|
|
let set_mode t new_mode = t.user_mode <- new_mode
|
2024-01-31 02:30:54 +00:00
|
|
|
let away t = t.away
|
|
|
|
let set_away t status = t.away <- status
|
2024-01-21 20:04:08 +00:00
|
|
|
|
2024-01-23 18:13:41 +00:00
|
|
|
let set_nick t new_nick =
|
2024-01-22 17:48:44 +00:00
|
|
|
begin
|
2024-01-21 20:04:08 +00:00
|
|
|
t.nick <- new_nick;
|
2024-01-22 17:48:44 +00:00
|
|
|
t.nick_key <- string_ci new_nick;
|
2024-01-21 20:04:08 +00:00
|
|
|
end
|
|
|
|
|
2024-01-23 18:13:41 +00:00
|
|
|
let register t ~router = Hashtbl.add router.users t.nick_key t
|
|
|
|
let unregister t ~router = Hashtbl.remove router.users t.nick_key
|
2024-01-23 18:46:48 +00:00
|
|
|
let is_registered t ~router = Hashtbl.mem router.users t.nick_key
|
2024-01-23 18:13:41 +00:00
|
|
|
|
|
|
|
let prefix t =
|
|
|
|
Irc.Msg.User_prefix (t.nick, Some t.userinfo)
|
|
|
|
|
2024-01-31 00:33:59 +00:00
|
|
|
let membership t =
|
|
|
|
Dllist.fold_r (fun m xs -> m :: xs) t.membership []
|
|
|
|
|
2024-01-23 18:13:41 +00:00
|
|
|
let channels t =
|
|
|
|
Dllist.fold_r (fun m xs -> m.mem_chan :: xs) t.membership []
|