[project @ 2002-07-24 03:05:06 by unknown_lamer]
[clinton/bobotpp.git] / scripts / bobot-utils.scm
index 89cd34b..d1963a3 100644 (file)
@@ -6,17 +6,17 @@
 
 ;;; Why the GPL? Technically anything that uses Bobot++'s functions
 ;;; must be GPLed, so all of your scripts have to be GPLed anyway
-;;; because you are really linking with Bobot++, a GPLed program!
+;;; because you are really linking with Bobot++, a GPLed program.
 
-;;; Bot load (loads a file from %bot-loadpath)
+;;; Bot load (loads a file from %bot:loadpath)
 
-(define %bot-loadpath (list
+(define %bot:loadpath (list
                       (string-append (getenv "HOME")
-                                     "/.bobotpp/scripts")
-                      bot-sys-scripts-dir))
+                                     "/.bobotpp/scripts/")
+                      bot:sys-scripts-dir))
 
-(define (bot-load file)
-  (let loop ((load-path %bot-loadpath))
+(define (bot:load file)
+  (let loop ((load-path %bot:loadpath))
     (if (not (null? load-path))
       (if (catch 'system-error
             (lambda ()
               #f ))
         #t
         (loop (cdr load-path)))
-      #f )))
-
+      (begin (bot:log "ERROR: File " file " Not Found!\n") #f))))
 
 ;;; REGEX UTILS
 
 ;;; match-not-channel adds a prefix regex to your regex so it doesn't
 ;;; match the sender or channel in a PUBLIC message
 (define (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
 (define (match-to-me regex)
-  (string-append (match-not-channel (bot-getnickname))
-                "[:,]*[[:space:][:graph:]]*" regex))
+  (string-append (match-not-channel (bot:getnickname))
+                "[[:space:][:graph:]]*" regex))
 
 
 ;;;; string-utils
 ;;; bot-log: Write as many messages as you want to the log.  If the
 ;;; arg is a thunk it will be executed and it's output will be
 ;;; written to the log
-(define (bot-log . messages)
-  (map 
+(define (bot:log . messages)
+  (for-each
    (lambda (x)
      (if (thunk? x)
        (display (x) (bot-logport))
        (display x (bot-logport))))
    messages )
-  (bot-flushport))
\ No newline at end of file
+  (bot:flushport))
+
+;;; Message sending utils
+
+;;; returns the CTCP quoted message
+(define (ctcp-quote message)
+  message) ; FIXME: fill me in
+
+;;; DEPRECATED FUNCTION NAMES
+;;; These are provided for backwards compatibility
+;;; and will be removed in the 2.3 dev tree
+
+(define bot-load bot:load)
+(define bot-action bot:action)
+(define bot-adduser bot:adduser)
+(define bot-addserver bot:addserver)
+(define bot-addshit bot:addshit)
+(define bot-ban bot:ban)
+(define bot-cycle bot:cycle)
+(define bot-deban bot:deban)
+(define bot-delserver bot:delserver)
+(define bot-deluser bot:deluser)
+(define bot-delshit bot:delshit)
+(define bot-deop bot:deop)
+(define bot-die bot:die)
+(define bot-do bot:do)
+(define bot-invite bot:invite)
+(define bot-join bot:join)
+(define bot-keep bot:keep)
+(define bot-kick bot:kick)
+(define bot-kickban bot:kickban)
+(define bot-lock bot:lock)
+(define bot-logport bot:logport)
+(define bot-mode bot:mode)
+(define bot-msg bot:msg)
+(define bot-nextserver bot:nextserver)
+(define bot-nick bot:nick)
+(define bot-op bot:op)
+(define bot-part bot:part)
+(define bot-reconnect bot:reconnect)
+(define bot-say bot:say)
+(define bot-server bot:server)
+(define bot-setversion bot:setversion)
+(define bot-tban bot:tban)
+(define bot-tkban bot:tkban)
+(define bot-topic bot:topic)
+(define bot-unlock bot:unlock)
+(define bot-getnickname bot:getnickname)
+(define bot-getserver bot:getserver)
+(define bot-getserverlist bot:getserverlist)
+(define bot-flush bot:flush)
+(define bot-flushport bot:flushport)
+(define bot-random bot:random)
+(define bot-addcommand bot:addcommand)
+(define bot-delcommand bot:delcommand)
+(define bot-addhook bot:addhook)
+(define bot-addtimer bot:addtimer)
+(define bot-deltimer bot:deltimer)
\ No newline at end of file