[project @ 2005-06-28 09:54:46 by unknown_lamer]
[clinton/bobotpp.git] / scripts / boulet
1 ;;; Activate or desactivate the bot
2 (define talk 1)
3 (define (shutup)
4 (set! talk 0)
5 )
6 (bot:addcommand "shutup" shutup #f 0 2)
7 (define (dotalk)
8 (set! talk 1)
9 )
10 (bot:addcommand "talk" dotalk #f 0 2)
11
12 ;;; Miscellaneous list functions
13 (define (removeChannel c l)
14 (if (null? l)
15 (list)
16 (let ((deb (car l)))
17 (if (string-ci=? c (car deb))
18 (cdr l)
19 (append (list deb) (removeChannel c (cdr l)))
20 )
21 )
22 )
23 )
24
25 (define (changeChannel c n l)
26 (if (null? l)
27 (list)
28 (let ((deb (car l)))
29 (if (string-ci=? c (car deb))
30 (append (list (list c n)) (cdr l))
31 (append (list deb) (changeChannel c n (cdr l)))
32 )
33 )
34 )
35 )
36
37 (define (addChannel c n l)
38 (append l (list (list c n)))
39 )
40
41 ;;; When someone joins a channel
42 (define dumbTimer (list))
43 (define (joinLourd n c)
44 (if (string-ci=? n (bot:getnickname))
45 (begin
46 (if (= 1 talk) (bot:say c "salut les gars, vous parlez de quoi ?"))
47 (set! dumbTimer (addChannel c (bot:addtimer (+ 600 (bot:random 3000)) (dumbLourd c)) dumbTimer))
48 )
49 (if (= 1 talk) (bot:say c (string-append "euh humm euh..., " n "... une ptite question...")))
50 )
51 )
52 (bot:addhook hooks/join ".*" joinLourd)
53
54 ;;; When someone leaves the channel
55 (define (partLourd n c)
56 (bot:flushport)
57 (if (not (string-ci=? n (bot:getnickname)))
58 (if (= 1 talk) (bot:msg n "hey, reviens, on s'amusait bien"))
59 (let* ((timer (assoc c dumbTimer)))
60 (bot:deltimer (cadr timer))
61 (set! dumbTimer (removeChannel c dumbTimer))
62 )
63 )
64 )
65 (bot:addhook hooks/part ".*" partLourd)
66
67 ;;; Random action to say something dumb
68 (define dumbList
69 (list "errr... umm umm !!"
70 "ahum. err... p'tite question !"
71 "putain, php c'est vraiment de la merde"
72 "quelle daube mysql !"
73 "xml ça sert vraiment à rien..."
74 "c'est moi ou orion ne marche pas ?"
75 "mais euh ça sert à quoi le palm pilot ?"
76 "je ne comprends pas, j'ai fait copier coller, et ça ne marche pas..."
77 "dites les gars, c'est quoi l'avenir d'internet ?")
78 )
79 (define (dumbLourd c)
80 (lambda ()
81 (if (= 1 talk) (bot:say c (list-ref dumbList (bot:random (length dumbList)))))
82 (set! dumbTimer (changeChannel c (bot:addtimer (+ 600 (bot:random 3000)) (dumbLourd c)) dumbTimer))
83 )
84 )
85
86 ;;; Misc
87 (bot:addhook hooks/public "oracle" (lambda (f t p) (if (= 1 talk) (bot:say t "oracle ! Un truc de dinosaures, ça !"))))
88 (bot:addhook hooks/public "linux" (lambda (f t p) (if (= 1 talk) (bot:say t (string-append f ", j'ai installé une Mandrake chez moi ce week-end, et j'ai réussi à faire marcher l'imprimante")))))
89 (bot:addhook hooks/public "boulet" (lambda (f t p) (if (= 1 talk) (bot:say t "on parle de moi ?"))))
90 (bot:addhook hooks/public "lourd" (lambda (f t p) (if (= 1 talk) (bot:say t "vous le dites si je suis lourd !"))))
91 (bot:addhook hooks/public "csn" (lambda (f t p) (if (= 1 talk) (bot:say t "ahahah, je ne partirai jamais !"))))
92 (bot:addhook hooks/public "manger|pizza|pasta" (lambda (f t p) (if (= 1 talk) (bot:say t "je peux venir manger avec vous ?"))))
93 (bot:addhook hooks/public "regarde" (lambda (f t p) (if (= 1 talk) (bot:action t "se lève pour regarder..."))))
94
95 ;;; 9h00, on arrive au boulot
96 (define (newDay l)
97 (if (not (null? l))
98 (begin
99 (bot:say (caar l) "Bonjour les gars")
100 (newDay (cdr l))
101 )
102 )
103 )
104 (bot:addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk)))
105
106 ;;; 18h00, il est temps de rentrer
107 (define (timeToGo l)
108 (if (not (null? l))
109 (begin
110 (bot:say (caar l) "à demain !")
111 (bot:action (caar l) "rentre chez lui...")
112 (timeToGo (cdr l))
113 )
114 )
115 )
116 (bot:addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))