mirror of https://github.com/nealey/irc-bot
Handle long lines better, change literal escape to \007
This commit is contained in:
parent
d6a497df30
commit
76dfcbf258
16
bot.ml
16
bot.ml
|
@ -8,8 +8,20 @@ let write iobuf command args text =
|
||||||
let cmd = Command.create None command args text in
|
let cmd = Command.create None command args text in
|
||||||
Iobuf.write iobuf cmd
|
Iobuf.write iobuf cmd
|
||||||
|
|
||||||
let msg iobuf recip text =
|
let rec msg iobuf recip text =
|
||||||
write iobuf "PRIVMSG" [recip] (Some text)
|
match text with
|
||||||
|
| "" -> ()
|
||||||
|
| _ ->
|
||||||
|
let tl = String.length text in
|
||||||
|
let s, rest =
|
||||||
|
if (tl > 400) then
|
||||||
|
((Str.string_before text 400) ^ "↩",
|
||||||
|
"↪" ^ (Str.string_after text 400))
|
||||||
|
else
|
||||||
|
(text, "")
|
||||||
|
in
|
||||||
|
write iobuf "PRIVMSG" [recip] (Some s);
|
||||||
|
msg iobuf recip rest
|
||||||
|
|
||||||
let split = Str.split (Str.regexp "[ \t]*\r?\n")
|
let split = Str.split (Str.regexp "[ \t]*\r?\n")
|
||||||
|
|
||||||
|
|
8
firebot
8
firebot
|
@ -8,13 +8,13 @@ firebot () {
|
||||||
echo "$args" | bc -l
|
echo "$args" | bc -l
|
||||||
;;
|
;;
|
||||||
units)
|
units)
|
||||||
src=$(echo "$args" | sed 's/ ->.*//')
|
src=$(printf "%s" "$args" | sed 's/ ->.*//')
|
||||||
dst=$(echo "$args" | sed 's/.*-> //')
|
dst=$(printf "%s" "$args" | sed 's/.*-> //')
|
||||||
units -1 -v -- "$src" "$dst"
|
units -1 -v -- "$src" "$dst"
|
||||||
;;
|
;;
|
||||||
.note)
|
.note)
|
||||||
who=$(echo $args | cut -d\ -f1 | tr -d -c A-Za-z0-9)
|
who=$(printf "%s" "$args" | sed 's/ .*//;s/[^-A-Za-z0-9]/./')
|
||||||
what=$(echo $args | cut -d\ -f2-)
|
what=$(printf "%s" "$args" | cut -d\ -f2-)
|
||||||
when=$(date)
|
when=$(date)
|
||||||
echo "($when) <$sender> $what" > notes/$who
|
echo "($when) <$sender> $what" > notes/$who
|
||||||
echo "I've left $who a note, $sender."
|
echo "I've left $who a note, $sender."
|
||||||
|
|
Loading…
Reference in New Issue