X-Git-Url: https://jxself.org/git/?p=8sync.git;a=blobdiff_plain;f=demos%2Fircbot.scm;h=202c18c2a866170b39cd71dff30496796020001f;hp=eec40faf4cfa9b30d00f35e69402fc006afde70a;hb=4e0dd1c6881754498c144f50db4158d4bff4b782;hpb=8f71a1c0f6ddc9e295d929480503222c6baf9e4e diff --git a/demos/ircbot.scm b/demos/ircbot.scm index eec40fa..202c18c 100755 --- a/demos/ircbot.scm +++ b/demos/ircbot.scm @@ -19,15 +19,33 @@ ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ;; 02110-1301 USA -(use-modules (eightsync systems irc)) +(use-modules (eightsync systems irc) + (eightsync agenda) + (ice-9 match)) (define (handle-message socket my-name speaker - channel-name message is-action) - (if is-action - (format #t "~a emoted ~s in channel ~a\n" - speaker message channel-name) - (format #t "~a said ~s in channel ~a\n" - speaker message channel-name))) + channel message is-action) + (define (looks-like-me? str) + (or (equal? str my-name) + (equal? str (string-concatenate (list my-name ":"))))) + (match (string-split message #\space) + (((? looks-like-me? _) action action-args ...) + (match action + ("botsnack" + (irc-format socket "PRIVMSG ~a :Yippie! *does a dance!*" channel)) + ;; Add yours here + (_ + (irc-format socket "PRIVMSG ~a :*stupid puppy look*" channel)))) + (_ + (cond + (is-action + (format #t "~a emoted ~s in channel ~a\n" + speaker message channel)) + (else + (format #t "~a said ~s in channel ~a\n" + speaker message channel)))))) (define main - (make-irc-bot-cli)) + (make-irc-bot-cli (make-handle-line + #:handle-privmsg (wrap-apply handle-message)))) +