PageRenderTime 36ms CodeModel.GetById 10ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

/vars.rkt

http://github.com/elibarzilay/rudybot
Unknown | 61 lines | 49 code | 12 blank | 0 comment | 0 complexity | 00f29620e8eb9f4d34632cd2c5f8d395 MD5 | raw file
 1#lang racket/base
 2
 3(require "utils.rkt")
 4(provide (all-defined-out))
 5
 6;; This value depends on the server; this seems to work for freenode
 7(define *my-nick*
 8  (box (from-env "BOTNICK" "rudybot")))
 9(define *my-master*
10  ;; use authentication by default, but allow to set a regexp for convenience
11  (box (let ([master (from-env "BOTMASTER" "")])
12         (and (not (equal? master ""))
13              (regexp (string-append "^" master "$"))))))
14
15;; This should probably be a hash table, keyed by network name.
16(define *initial-channels* ; env var can be "#foo,#bar"
17  (make-parameter (from-env "BOTCHANNELS" '(
18                                            "##SICP"
19                                            "##cinema"
20                                            "#emacs"
21                                            "#racket"
22                                            "#scheme"
23                                            ) #rx",")))
24(define *nickserv-password*
25  (make-parameter (from-env "BOTPASSWD" #f)))
26(define *bot-gives-up-after-this-many-silent-seconds* (make-parameter 250))
27(define *irc-server-hostname* (make-parameter "localhost"))
28(define *irc-server-port* (make-parameter "6667"))
29
30(define *sandboxes* (make-hash))
31(define *max-values-to-display* 5)
32
33(define *start-time*            (current-seconds))
34(define *connection-start-time* (make-parameter #f))
35
36;; some state is put globally, to be able to separate functions conveniently
37(define *irc-output*      (make-parameter #f))
38(define *current-words*   (make-parameter #f))
39(define *response-target* (make-parameter #f))
40(define *for-whom*        (make-parameter #f))
41(define *full-id*         (make-parameter #f))
42
43;; Not sure it makes sense for these two to be separate; but adding
44;; *incubot-logger* seemed the quickest way to get logging in incubot
45(define *logger*          (make-parameter #f))
46(define *incubot-logger*  (make-parameter #f))
47
48(provide log)
49(define (log fmt . args)
50  (apply (*logger*) fmt args))
51
52
53;; Maybe I should use rnrs/enums-6 to guard against typos
54(define *authentication-state* (box 'havent-even-tried))
55
56;; Lines much longer than this will cause the server to kick us for
57;; flooding.
58(define *max-output-line* 500)
59
60;; This retrieves a sentence from the "incubot" server.
61(define *incubot-server* (make-parameter (lambda ignored #f)))