X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=demos%2Fircbot.scm;h=350611138924e7a58254875e67afee5d1e21f768;hb=0d10b58e73e1ef034b2f1b47fdd31b4ff45d3ce3;hp=00c48ffe2eef8d6883802f78fd1918ba9c6353ef;hpb=4998e7a9fe3b303923d918cd6087633d5302274f;p=8sync.git diff --git a/demos/ircbot.scm b/demos/ircbot.scm index 00c48ff..3506111 100755 --- a/demos/ircbot.scm +++ b/demos/ircbot.scm @@ -1,4 +1,4 @@ -#!/usr/bin/guile \ +#! /usr/bin/env guile \ -e main -s !# @@ -21,6 +21,7 @@ ;;; License along with 8sync. If not, see . (use-modules (8sync) + (8sync contrib irc) (8sync systems irc) (8sync repl) (oop goops) @@ -30,38 +31,48 @@ (define-class ()) -(define-method (handle-line (irc-bot ) message - speaker channel line emote?) +(define-method (handle-message (irc-bot ) message) (define my-name (irc-bot-username irc-bot)) (define (looks-like-me? str) (or (equal? str my-name) (equal? str (string-concatenate (list my-name ":"))))) - (match (string-split line #\space) - (((? looks-like-me? _) action action-args ...) - (match action - ;; The classic botsnack! - ("botsnack" - (<- (actor-id irc-bot) 'send-line channel - "Yippie! *does a dance!*")) - ;; Return greeting - ((or "hello" "hello!" "hello." "greetings" "greetings." "greetings!" - "hei" "hei." "hei!" "hi" "hi!") - (<- (actor-id irc-bot) 'send-line channel - (format #f "Oh hi ~a!" speaker))) - ;; ---> Add yours here <--- + (match message + ((and ($ ) + (= irc:message-line line) + (= irc:message-command 'PRIVMSG) + (= irc:message-speaker speaker) + (= irc:message-channel channel) + (= irc:message-message message) + (= irc:message-emote? emote?)) - ;; Default + (match (string-split message #\space) + (((? looks-like-me? _) action action-args ...) + (match action + ;; The classic botsnack! + ("botsnack" + (<- (actor-id irc-bot) 'send-line channel + "Yippie! *does a dance!*")) + ;; Return greeting + ((or "hello" "hello!" "hello." "greetings" "greetings." "greetings!" + "hei" "hei." "hei!" "hi" "hi!") + (<- (actor-id irc-bot) 'send-line channel + (format #f "Oh hi ~a!" speaker))) + + ;; ---> Add yours here <--- + + ;; Default + (_ + (<- (actor-id irc-bot) 'send-line channel + "*stupid puppy look*")))) + ;; Otherwise... just spit the output to current-output-port or whatever (_ - (<- (actor-id irc-bot) 'send-line channel - "*stupid puppy look*")))) - ;; Otherwise... just spit the output to current-output-port or whatever - (_ - (if emote? - (format #t "~a emoted ~s in channel ~a\n" - speaker line channel) - (format #t "~a said ~s in channel ~a\n" - speaker line channel))))) + (if emote? + (format #t "~a emoted ~s in channel ~a\n" + speaker message channel) + (format #t "~a said ~s in channel ~a\n" + speaker message channel))))) + (_ #f))) (define (display-help scriptname)