Handle long lines better, change literal escape to \007

This commit is contained in:
Neale Pickett 2010-12-16 17:28:43 -07:00
parent d6a497df30
commit 76dfcbf258
3 changed files with 19 additions and 7 deletions

16
bot.ml
View File

@ -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")

View File

@ -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."

View File

@ -37,7 +37,7 @@ EOF
!l*) !l*)
printf "%s" "$args" printf "%s" "$args"
cdb -q -m $db "$args" | \ cdb -q -m $db "$args" | \
awk '{printf(" | \"%s\"", $0);}' awk '{printf("¦\"%s\"", $0);}'
echo echo
;; ;;
!a*) !a*)