1 ;;; -*- guile-scheme -*-
2 ;;; this shows off some interesting things...(based on boulet)
3 ;;; This is unknown_lamer's bot DumbBot
7 ;;; cat sayings | guile -s insert_saying.scm
8 ;;; Then load this file.
9 ;;; To add a new saying to the bot db just run insert_saying.scm
11 ;;; yes, this uses a sql db!
12 (use-modules (database simplesql)
14 (load "../bobot-utils.scm")
16 ;;; Activate or desactivate the bot
21 (bot-addcommand "shutup" shutup #f 0 2)
25 (bot-addcommand "talk" dotalk #f 0 2)
28 ;;; Miscellaneous list functions
29 (define (removeChannel c l)
33 (if (string-ci=? c (car deb))
35 (append (list deb) (removeChannel c (cdr l)))))))
37 (define (changeChannel c n l)
41 (if (string-ci=? c (car deb))
42 (append (list (list c n)) (cdr l))
43 (append (list deb) (changeChannel c n (cdr l)))))))
45 (define (addChannel c n l)
46 (append l (list (list c n))))
48 ;;; When someone joins a channel
49 (define dumbTimer (list))
50 (define (joinLourd n c)
51 (if (string-ci=? n (bot-getnickname))
53 (if (= 1 talk) (bot-say c "I like limos"))
55 (addChannel c (bot-addtimer (+ 600 (bot-random 300))
56 (dumbLourd c)) dumbTimer)))
57 (if (= 1 talk) (bot-say c (string-append "Arf Moo Arf! " n
58 " I like pizza...")))))
59 (bot-addhook hooks/join ".*" joinLourd)
61 ;;; When someone leaves the channel
62 (define (partLourd n c)
64 (if (not (string-ci=? n (bot-getnickname)))
65 (if (= 1 talk) (bot-msg n "I HATED YOU ANYWAY"))
66 (let* ((timer (assoc c dumbTimer)))
67 (bot-deltimer (cadr timer))
68 (set! dumbTimer (removeChannel c dumbTimer)))))
69 (bot-addhook hooks/part ".*" partLourd)
71 ;;; Random action to say something dumb
77 (vector-ref (list-ref dumbList (bot-random (length dumbList))) 0)))
81 (bot-addtimer (+ 600 (bot-random 300)) (dumbLourd c)) dumbTimer))))
84 (define dumbDB (simplesql-open 'postgresql "bot_sayings"))
86 ; (define (reload-sayings)
87 ; (set! dumbList (cdr (simplesql-query dumbDB "SELECT saying FROM sayings")))
88 ; (display "Reloaded sayings from db\n" (bot-logport))
90 ; (bot-addcommand "reloadsayings" reload-sayings #f 0 4)
99 "SELECT count(saying) FROM sayings")) 0) 0))))
102 (define (_select db entry)
106 (str-app "SELECT saying FROM sayings "
108 (number->string entry)))) 0))
113 (define (random-saying)
114 (vector-ref (_select dumbDB (bot-random (_length dumbDB))) 0))
117 ;;; note that public hooks match the channel name too!
118 ;;; match-not-channel prevents this
120 ;;; this should be the first so it doesn't clobber the other hooks
122 hooks/public (match-to-me "")
126 (string-append f ": " (random-saying))))) -50 #f)
129 (bot-addhook hooks/public (match-not-channel "oracle")
132 (bot-say t "Oracle is evil! Use Postgres instead!"))))
134 (define (add-gnu word)
135 (bot-addhook hooks/public (match-not-channel word)
139 (string-append f ": I hope you meant GNU!"))))))
140 (map add-gnu '("[^/g]linux" "microsoft" "bsd"))
142 (bot-addhook hooks/public (match-not-channel "boulet")
144 (if (= 1 talk) (bot-say t "on parle de moi ?"))))
146 (bot-addhook hooks/public (match-not-channel "arf")
149 (bot-say t (random-saying)))))
151 (bot-addhook hooks/public (match-not-channel "csn")
153 (if (= 1 talk) (bot-say t "???"))))
155 (bot-addhook hooks/public (match-not-channel "pizza|pasta|soda")
158 (bot-say t (string-append f ": give me one too!")))))
160 (define (add-foul word)
161 (bot-addhook hooks/public (match-not-channel word)
165 t (string-append "hits " f
166 " for having a potty mouth"))))))
167 (map add-foul '("bitch" "fuck" "whore" "cunt" "tit" "shit" "dick" "cock"))
169 (bot-addhook hooks/public (match-not-channel "anal sex")
172 (if (not (string-match "unknown_lamer" f))
174 t (string-append "grabs " f
175 " and buggers " f " up the ass"))))))
178 hooks/public (match-not-channel "[[:space:]]*lame[[:space:]]+")
182 (string-append f ": NO NO YOU ARE THE LAMER")))))
184 (bot-addhook hooks/public (match-to-me "burn")
189 (string-append "How about you burn " f "?")))))
192 ;;; 9h00, on arrive au boulot
194 ; (if (not (null? l))
196 ; (bot-say (caar l) "What is up my homey g-d0g?")
202 ;(bot-addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk)))
204 ;;; 18h00, il est temps de rentrer
205 ;(define (timeToGo l)
206 ; (if (not (null? l))
208 ; (bot-say (caar l) "Give me food")
209 ; (bot-action (caar l) "I'm bored")
214 ;(bot-addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))