fix a stupid `get_command` bug
This commit is contained in:
parent
33974047be
commit
7c18bfb7a2
|
@ -41,7 +41,12 @@ 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 =
|
||||
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 =
|
||||
|
@ -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 &&
|
||||
|
|
|
@ -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 ^ ")"
|
||||
|
|
Loading…
Reference in New Issue