open! Import include Router_types type t = user let make nick ~userinfo ~outbox = { outbox; userinfo; nick; nick_key = string_ci nick; user_mode = Irc.Mode.Set.empty; 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 let set_nick t new_nick = begin t.nick <- new_nick; t.nick_key <- string_ci new_nick; end let register t ~router = Hashtbl.add router.users t.nick_key t let unregister t ~router = Hashtbl.remove router.users t.nick_key let is_registered t ~router = Hashtbl.mem router.users t.nick_key let prefix t = Irc.Msg.User_prefix (t.nick, Some t.userinfo) let channels t = Dllist.fold_r (fun m xs -> m.mem_chan :: xs) t.membership []