Browse Source

fix a stupid `get_command` bug

master
epic morphism 2 years ago
parent
commit
7c18bfb7a2
  1. 10
      connection.ml
  2. 2
      vantabot.ml

10
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 &&

2
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 ^ ")"

Loading…
Cancel
Save