[project @ 2002-07-07 02:33:51 by unknown_lamer]
[clinton/bobotpp.git] / scripts / bobot-utils.scm
CommitLineData
cb21075d 1;;; this is a library of stuff that bobot++ scripts would probably
2;;; want to use.
3
4;;; This file is covered by the GPL version 2 or (at your option) any
5;;; later version
6
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!
10
11;;; REGEX UTILS
12
13;;; match-not-channel adds a prefix regex to your regex so it doesn't
14;;; match the sender or channel in a PUBLIC message
15(define (match-not-channel regex)
16 (string-append "[[:graph:]]* [&#+!][^ ,\a]+ [[:graph:][:space:]]*" regex))
17
18;;; match-to-me matches text that was addressed to the bot with a
19;;; ':',',', or nothing after the bot name
20(define (match-to-me regex)
21 (string-append (match-not-channel (bot-getnickname))
22 "[:,]*[[:space:][:graph:]]*" regex))
23
24
25;;;; string-utils
26(define str-app string-append) ; shorter
27
28
29;;;; Misc UTILS
30
31;;; bot-log: Write as many messages as you want to the log. If the
32;;; arg is a procedure it will be executed and it's output will be
33;;; written to the log
34(define (bot-log . messages)
35 (map
36 (lambda (x)
37 (if (procedure? x)
38 (display (x) (bot-logport))
39 (display x (bot-logport))))
40 messages )
41 (bot-flushport))