diff --git a/connection.ml b/connection.ml index 95090b8..8660001 100644 --- a/connection.ml +++ b/connection.ml @@ -41,8 +41,13 @@ module Conn (C: CLIENT with type 'a Io.t = 'a Lwt.t) = struct match String.split_on_char '!' wh with | a::_ -> a | [] -> "" + let register_callback ~prefix ~callback = - callbacks := (prefix,callback)::!callbacks + if List.mem_assoc prefix !callbacks + then + callbacks := (prefix,callback)::List.remove_assoc prefix !callbacks + else + callbacks := (prefix,callback)::!callbacks let get_command botnick msg pref = let nl = String.length botnick in @@ -51,7 +56,8 @@ module Conn (C: CLIENT with type 'a Io.t = 'a Lwt.t) = struct if String.get msg 0 = '!' then (* If it's a command starting with "!" *) let msg = String.sub msg 1 (String.length msg - 1) in - if String.length msg >= n then + if String.length msg >= n && + String.sub msg 0 n = pref then Some (String.sub msg n (String.length msg - n)) else None else if String.length msg >= k && diff --git a/vantabot.ml b/vantabot.ml index 3731bc7..d73a65d 100644 --- a/vantabot.ml +++ b/vantabot.ml @@ -21,7 +21,7 @@ let countdown = ref 5 let db_file = ref "toke.db" let smolchannels = ["#tildetown"] -let bigchannels = ["#bots";"#aaa"] +let bigchannels = ["#bots"] let options = Arg.align [ "-host", Arg.Set_string host, " server host name (default: " ^ !host ^ ")"