;;; match-not-channel adds a prefix regex to your regex so it doesn't
;;; match the sender or channel in a PUBLIC message
(define-public (bot:match-not-channel regex)
- (string-append "^[[:graph:]]* [&#+!][^ ,\a]+ [[:graph:][:space:]]*" regex))
+ (string-append "^[[:graph:]]* [&#+!][^ ,\a]+ [[:graph:][:space:]]*"
+ regex))
;;; match-to-me matches text that was addressed to the bot with a
;;; ':',',', or nothing after the bot name
(string-append (bot:match-not-channel (bot:getnickname))
"[[:space:][:graph:]]*" regex))
-(define-public (bot:sent-to-me? message)
+(define-public bot:sent-to-me?
(let ((to-me (make-regexp (bot:match-to-me ""))))
- (if (regexp-exec to-me message) #t #f)))
+ (lambda (message)
+ (if (regexp-exec to-me message) #t #f))))
;;;; string-utils
(define-public str-app string-append) ; shorter
(string-concatenate
(map (lambda (chr) ; CTCP level quoting
(case (char->integer chr)
- ((#o134) (string (integer->char #o134) (integer->char #o134)))
+ ((#o134) (string (integer->char #o134) (integer->char
+ #o134)))
((#o01) (string (integer->char #o134) #\a)) ; X-DELIM
(else (string chr))))
(string->list