1 ;;; this is a library of stuff that bobot++ scripts would probably
2 ;;; want to use. This file is autoloaded by bobot++
4 ;;; This file is covered by the GPL version 2 or (at your option) any
7 ;;; Why the GPL? Technically anything that uses Bobot++'s functions
8 ;;; must be GPLed, so all of your scripts have to be GPLed anyway
9 ;;; because you are really linking with Bobot++, a GPLed program!
11 ;;; Bot load (loads a file from %bot-loadpath)
13 (define %bot-loadpath (list
14 (string-append (getenv "HOME")
18 (define (bot-load file)
19 (let loop ((load-path %bot-loadpath))
20 (if (not (null? load-path))
21 (if (catch 'system-error
24 (string-append (car load-path)
29 (loop (cdr load-path)))
35 ;;; match-not-channel adds a prefix regex to your regex so it doesn't
36 ;;; match the sender or channel in a PUBLIC message
37 (define (match-not-channel regex)
38 (string-append "[[:graph:]]* [&#+!][^ ,\a]+ [[:graph:][:space:]]*" regex))
40 ;;; match-to-me matches text that was addressed to the bot with a
41 ;;; ':',',', or nothing after the bot name
42 (define (match-to-me regex)
43 (string-append (match-not-channel (bot-getnickname))
44 "[:,]*[[:space:][:graph:]]*" regex))
48 (define str-app string-append) ; shorter
53 ;;; bot-log: Write as many messages as you want to the log. If the
54 ;;; arg is a thunk it will be executed and it's output will be
55 ;;; written to the log
56 (define (bot-log . messages)
60 (display (x) (bot-logport))
61 (display x (bot-logport))))