From d7e76775473bc21793b091f629213f3d69557a9e Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 3 Mar 2009 17:56:07 -0700 Subject: [PATCH] Expanded notion of channels --- TODO | 4 +++- bot.ml | 4 ++-- irc.ml | 5 +++++ irc.mli | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index a767caf..45c7921 100644 --- a/TODO +++ b/TODO @@ -1 +1,3 @@ -* +* Modify Ocs_port to use Buffer instead of String + + diff --git a/bot.ml b/bot.ml index 18db4f0..210c87a 100644 --- a/bot.ml +++ b/bot.ml @@ -84,11 +84,11 @@ let handle_command iobuf cmd = | (_, "PING", _, text) -> write iobuf "PONG" [] text | (_, "001", _, _) -> - write iobuf "JOIN" ["#bot"] None + write iobuf "JOIN" ["+bot"] None | (Some sender, "JOIN", [], Some chan) -> write iobuf "PRIVMSG" [chan] (Some "hi asl") | (Some sender, "PRIVMSG", [target], Some text) -> - if target.[0] = '#' then + if Irc.is_channel target then handle_privmsg iobuf sender target text | _ -> () diff --git a/irc.ml b/irc.ml index 26bf66d..ebe14f6 100644 --- a/irc.ml +++ b/irc.ml @@ -8,6 +8,11 @@ let dbg msg a = prerr_endline ("[" ^ msg ^ "]"); a +let is_channel str = + match str with + | '#' | '+' | '&' -> true + | _ -> false + let string_map f s = let l = String.length s in if l = 0 then diff --git a/irc.mli b/irc.mli index 0d313c5..489e442 100644 --- a/irc.mli +++ b/irc.mli @@ -5,6 +5,7 @@ val name : string ref val version : string val start_time : float +val is_channel : string -> bool val uppercase : string -> string val lowercase : string -> string val truncate : string -> int -> string