[Cleaned up examples and scripts clinton@unknownlamer.org**20081113004349 * Config example is in examples/config now * Example scripts are in examples/scripts instead of interspersed with the installed bobot++ modules * Removed broken and crappy example ] { adddir ./examples/config move ./examples/bot.autoexec ./examples/config/bot.autoexec move ./examples/bot.conf ./examples/config/bot.conf move ./examples/bot.help ./examples/config/bot.help move ./examples/bot.init ./examples/config/bot.init move ./examples/bot.shit ./examples/config/bot.shit move ./examples/bot.users ./examples/config/bot.users move ./examples/scripts.load ./examples/config/scripts.load adddir ./examples/scripts move ./scripts/boulet ./examples/scripts/boulet move ./scripts/country ./examples/scripts/country move ./scripts/eval ./examples/scripts/eval move ./scripts/hello ./examples/scripts/hello move ./scripts/log.scm ./examples/scripts/log.scm move ./scripts/scheme_add_user ./examples/scripts/scheme_add_user move ./scripts/tamere ./examples/scripts/tamere move ./scripts/uname ./examples/scripts/uname move ./scripts/uptime ./examples/scripts/uptime hunk ./scripts/stupid_stuff/insert_saying.scm 1 -#!/usr/local/bin/guile -s -!# - -(use-modules (database simplesql) - (ice-9 rdelim)) - -(display "Enter one saying per line. End the list with EOF\n") - -(define db (simplesql-open 'postgresql "bot_sayings")) - -(let loop ((saying (read-line))) - (cond ((not (eof-object? saying)) - (simplesql-query - db - (string-append "INSERT INTO sayings VALUES ('" - (simplesql-escape saying) "');")) - (loop (read-line))) - (else - (simplesql-close db)))) + rmfile ./scripts/stupid_stuff/insert_saying.scm hunk ./scripts/stupid_stuff/sayings 1 -Arf! -errr... umm umm !! -I think the real issue here is how do you make juice-juice? -I like to eat cows. -MySQL is stupid -I used to speak french -c'est moi ou orion ne marche pas ? -1 4m m0r3 l33t th4n j00! -BITCH, WUT? -vergil gives wicked hummers! -Ahh! Snakes! -I like limos and people who drive them. -Eat Cows today! -Over [5] customers served since 1996! -I think I'll go and hang myself now! -I'd leap off a third floor balcony for ice cream! -I am immune to all forms of temptation and seduction. Except for Cute. -I am a kernel whore. -Doesn't is just suck when you get soap in your orange juice? rmfile ./scripts/stupid_stuff/sayings hunk ./scripts/stupid_stuff/sayings.sh 1 -#!/bin/sh - -createdb bot_sayings -psql bot_sayings -c "CREATE TABLE sayings ( saying text, id serial);" + rmfile ./scripts/stupid_stuff/sayings.sh hunk ./scripts/stupid_stuff/stupid_stuff 1 -;;; -*- guile-scheme -*- -;;; this shows off some interesting things...(based on boulet) -;;; This is unknown_lamer's bot DumbBot - -;;; To use this run: -;;; sh sayings.sh -;;; cat sayings | guile -s insert_saying.scm -;;; Then load this file. -;;; To add a new saying to the bot db just run insert_saying.scm - -;;; yes, this uses a sql db! -(use-modules (database simplesql) - (ice-9 debug)) -(load "../bobot:utils.scm") - -;;; 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 "I like limos")) - (set! dumbTimer - (addChannel c (bot:addtimer (+ 600 (bot:random 300)) - (dumbLourd c)) dumbTimer))) - (if (= 1 talk) (bot:say c (string-append "Arf Moo Arf! " n - " I like pizza..."))))) -(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 "I HATED YOU ANYWAY")) - (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 (dumbLourd c) - (lambda () - (if (= 1 talk) - (bot:say - c - (vector-ref (list-ref dumbList (bot:random (length dumbList))) 0))) - (set! dumbTimer - (changeChannel - c - (bot:addtimer (+ 600 (bot:random 300)) (dumbLourd c)) dumbTimer)))) - - -(define dumbDB (simplesql-open 'postgresql "bot_sayings")) -;(define dumbList #f) -; (define (reload-sayings) -; (set! dumbList (cdr (simplesql-query dumbDB "SELECT saying FROM sayings"))) -; (display "Reloaded sayings from db\n" (bot:logport)) -; (bot:flushport)) -; (bot:addcommand "reloadsayings" reload-sayings #f 0 4) -; (reload-sayings) - -(define (_length db) - (let ((length (+ 1 - (vector-ref - (list-ref (cdr - (simplesql-query - db - "SELECT count(saying) FROM sayings")) 0) 0)))) - length )) - -(define (_select db entry) - (list-ref - (cdr - (simplesql-query db - (str-app "SELECT saying FROM sayings " - "WHERE id = " - (number->string entry)))) 0)) - - - - -(define (random-saying) - (vector-ref (_select dumbDB (bot:random (_length dumbDB))) 0)) - -;;; Misc -;;; note that public hooks match the channel name too! -;;; match-not-channel prevents this - -;;; this should be the first so it doesn't clobber the other hooks -(bot:addhook - hooks/public (match-to-me "") - (lambda (f t p) - (if (= 1 talk) - (bot:say t - (string-append f ": " (random-saying))))) -50 #f) - - -(bot:addhook hooks/public (match-not-channel "oracle") - (lambda (f t p) - (if (= 1 talk) - (bot:say t "Oracle is evil! Use Postgres instead!")))) - -(define (add-gnu word) - (bot:addhook hooks/public (match-not-channel word) - (lambda (f t p) - (if (= 1 talk) - (bot:say t - (string-append f ": I hope you meant GNU!")))))) -(map add-gnu '("[^/g]linux" "microsoft" "bsd")) - -(bot:addhook hooks/public (match-not-channel "boulet") - (lambda (f t p) - (if (= 1 talk) (bot:say t "on parle de moi ?")))) - -(bot:addhook hooks/public (match-not-channel "arf") - (lambda (f t p) - (if (= 1 talk) - (bot:say t (random-saying))))) - -(bot:addhook hooks/public (match-not-channel "csn") - (lambda (f t p) - (if (= 1 talk) (bot:say t "???")))) - -(bot:addhook hooks/public (match-not-channel "pizza|pasta|soda") - (lambda (f t p) - (if (= 1 talk) - (bot:say t (string-append f ": give me one too!"))))) - -(define (add-foul word) - (bot:addhook hooks/public (match-not-channel word) - (lambda (f t p) - (if (= 1 talk) - (bot:action - t (string-append "hits " f - " for having a potty mouth")))))) -(map add-foul '("bitch" "fuck" "whore" "cunt" "tit" "shit" "dick" "cock")) - -(bot:addhook hooks/public (match-not-channel "anal sex") - (lambda (f t p) - (if (= 1 talk) - (if (not (string-match "unknown_lamer" f)) - (bot:action - t (string-append "grabs " f - " and buggers " f " up the ass")))))) - -(bot:addhook - hooks/public (match-not-channel "[[:space:]]*lame[[:space:]]+") - (lambda (f t p) - (if (= 1 talk) - (bot:say t - (string-append f ": NO NO YOU ARE THE LAMER"))))) - -(bot:addhook hooks/public (match-to-me "burn") - (lambda (f t p) - (if (= 1 talk) - (bot:say - t - (string-append "How about you burn " f "?"))))) - - -;;; 9h00, on arrive au boulot -;(define (newDay l) -; (if (not (null? l)) -; (begin -; (bot:say (caar l) "What is up my homey g-d0g?") -; (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) "Give me food") -; (bot:action (caar l) "I'm bored") -; (timeToGo (cdr l)) -; ) -; ) -;) -;(bot:addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup))) + rmfile ./scripts/stupid_stuff/stupid_stuff rmdir ./scripts/stupid_stuff hunk ./Makefile.am 3 -EXTRA_DIST = examples m4 scripts +EXTRA_DIST = examples m4 hunk ./scripts/scripts.load 1 -(stupid_stuff stupid_stuff) -(country) -(hello) -(tamere) -(uname) -(uptime) -(eval) + rmfile ./scripts/scripts.load }