X-Git-Url: https://git.hcoop.net/clinton/bobotpp.git/blobdiff_plain/c6e7af0589e98d7e6e6e233eb6fc88f9aba3c098..528799bd9ee2c03de68c6d2dc20a4813da3e3261:/scripts/bobot-utils.scm diff --git a/scripts/bobot-utils.scm b/scripts/bobot-utils.scm index 1892ec1..916a76e 100644 --- a/scripts/bobot-utils.scm +++ b/scripts/bobot-utils.scm @@ -79,7 +79,8 @@ ;;; 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 @@ -87,9 +88,10 @@ (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 @@ -105,7 +107,8 @@ (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