;;; Activate or desactivate the bot (define talk 1) (define (shutup) (set! talk 0) ) (bot:addcommand "shutup" shutup #f 0 2) (define (dotalk) (set! talk 1) ) (bot:addcommand "talk" dotalk #f 0 2) ;;; Miscellaneous list functions (define (removeChannel c l) (if (null? l) (list) (let ((deb (car l))) (if (string-ci=? c (car deb)) (cdr l) (append (list deb) (removeChannel c (cdr l))) ) ) ) ) (define (changeChannel c n l) (if (null? l) (list) (let ((deb (car l))) (if (string-ci=? c (car deb)) (append (list (list c n)) (cdr l)) (append (list deb) (changeChannel c n (cdr l))) ) ) ) ) (define (addChannel c n l) (append l (list (list c n))) ) ;;; When someone joins a channel (define dumbTimer (list)) (define (joinLourd n c) (if (string-ci=? n (bot:getnickname)) (begin (if (= 1 talk) (bot:say c "salut les gars, vous parlez de quoi ?")) (set! dumbTimer (addChannel c (bot:addtimer (+ 600 (bot:random 3000)) (dumbLourd c)) dumbTimer)) ) (if (= 1 talk) (bot:say c (string-append "euh humm euh..., " n "... une ptite question..."))) ) ) (bot:addhook hooks/join ".*" joinLourd) ;;; When someone leaves the channel (define (partLourd n c) (bot:flushport) (if (not (string-ci=? n (bot:getnickname))) (if (= 1 talk) (bot:msg n "hey, reviens, on s'amusait bien")) (let* ((timer (assoc c dumbTimer))) (bot:deltimer (cadr timer)) (set! dumbTimer (removeChannel c dumbTimer)) ) ) ) (bot:addhook hooks/part ".*" partLourd) ;;; Random action to say something dumb (define dumbList (list "errr... umm umm !!" "ahum. err... p'tite question !" "putain, php c'est vraiment de la merde" "quelle daube mysql !" "xml ça sert vraiment à rien..." "c'est moi ou orion ne marche pas ?" "mais euh ça sert à quoi le palm pilot ?" "je ne comprends pas, j'ai fait copier coller, et ça ne marche pas..." "dites les gars, c'est quoi l'avenir d'internet ?") ) (define (dumbLourd c) (lambda () (if (= 1 talk) (bot:say c (list-ref dumbList (bot:random (length dumbList))))) (set! dumbTimer (changeChannel c (bot:addtimer (+ 600 (bot:random 3000)) (dumbLourd c)) dumbTimer)) ) ) ;;; Misc (bot:addhook hooks/public "oracle" (lambda (f t p) (if (= 1 talk) (bot:say t "oracle ! Un truc de dinosaures, ça !")))) (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"))))) (bot:addhook hooks/public "boulet" (lambda (f t p) (if (= 1 talk) (bot:say t "on parle de moi ?")))) (bot:addhook hooks/public "lourd" (lambda (f t p) (if (= 1 talk) (bot:say t "vous le dites si je suis lourd !")))) (bot:addhook hooks/public "csn" (lambda (f t p) (if (= 1 talk) (bot:say t "ahahah, je ne partirai jamais !")))) (bot:addhook hooks/public "manger|pizza|pasta" (lambda (f t p) (if (= 1 talk) (bot:say t "je peux venir manger avec vous ?")))) (bot:addhook hooks/public "regarde" (lambda (f t p) (if (= 1 talk) (bot:action t "se lève pour regarder...")))) ;;; 9h00, on arrive au boulot (define (newDay l) (if (not (null? l)) (begin (bot:say (caar l) "Bonjour les gars") (newDay (cdr l)) ) ) ) (bot:addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk))) ;;; 18h00, il est temps de rentrer (define (timeToGo l) (if (not (null? l)) (begin (bot:say (caar l) "à demain !") (bot:action (caar l) "rentre chez lui...") (timeToGo (cdr l)) ) ) ) (bot:addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))