Start at channels

This commit is contained in:
Neale Pickett 2008-03-19 16:19:24 -06:00
parent 167105c661
commit 68428d8347
6 changed files with 33 additions and 13 deletions

View File

@ -1,14 +1,18 @@
type t = {name: string}
module String_map =
Map.Make (struct
type t = string
let compare = compare
end)
let modes = "t"
type client = Iobuf.t * Irc.nuhost
let by_name = Hashtbl.create 25
type t = {name: string;
modes: string ref;
clients: client String_map.t}
let lookup name =
Hashtbl.find by_name name
let modes = "aimnqpsrtklb"
let create name =
{name = name}
let channels = String_map.empty
let is_channel_name name =
match name.[0] with
@ -16,4 +20,11 @@ let is_channel_name name =
true
| _ ->
false
let has_mode chan mode =
String.contains !(chan.modes) mode
let handle_command iobuf (nick, username, hostname) cmd =
match (Command.as_tuple cmd) with
| _ ->
()

View File

@ -1,8 +1,12 @@
type t
(* Channels handle:
MODE, JOIN, PART, TOPIC, NAMES, LIST, INVITE, KICK, PRIVMSG, NOTICE
*)
val modes : string
val lookup : string -> t
val create : string -> t
val handle_command : Iobuf.t -> Irc.nuhost -> Command.t -> unit
val is_channel_name : string -> bool

View File

@ -26,8 +26,8 @@ let error num args text =
let uhost cli =
(!(cli.nick) ^ "!" ^ cli.username ^ "@" ^ (Iobuf.addr cli.iobuf))
let close cli =
Iobuf.close cli.iobuf
let kill cli message =
Iobuf.close cli.iobuf ("Killed: " ^ message)
let write_command cli cmd =
Iobuf.write cli.iobuf cmd

2
irc.ml
View File

@ -1,3 +1,5 @@
type nuhost = (string * string * string)
let name = ref "irc.test"
let version = "0.1"
let start_time = Unix.gettimeofday ()

View File

@ -1,3 +1,6 @@
(** (Nickname, username, hostname) tuple *)
type nuhost = (string * string * string)
val name : string ref
val version : string
val start_time : float

View File

@ -340,7 +340,7 @@ let do_login nick =
Recv (":testserver.test 001 " ^ nick ^ " :Welcome to IRC.\r\n");
Recv (":testserver.test 002 " ^ nick ^ " :I am testserver.test Running version " ^ Irc.version ^ "\r\n");
Recv (":testserver.test 003 " ^ nick ^ " :This server was created " ^ (string_of_float Irc.start_time) ^ "\r\n");
Recv (":testserver.test 004 " ^ nick ^ " :testserver.test 0.1 l t\r\n");
Recv (":testserver.test 004 " ^ nick ^ " :testserver.test 0.1 l aimnqpsrtklb\r\n");
]
let regression_tests =