5 ;;; 8sync --- Asynchronous programming for Guile
6 ;;; Copyright (C) 2015 Christopher Allan Webber <cwebber@dustycloud.org>
8 ;;; This file is part of 8sync.
10 ;;; 8sync is free software: you can redistribute it and/or modify it
11 ;;; under the terms of the GNU Lesser General Public License as
12 ;;; published by the Free Software Foundation, either version 3 of the
13 ;;; License, or (at your option) any later version.
15 ;;; 8sync is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU Lesser General Public License for more details.
20 ;;; You should have received a copy of the GNU Lesser General Public
21 ;;; License along with 8sync. If not, see <http://www.gnu.org/licenses/>.
23 (use-modules (8sync systems irc)
27 (define (handle-message socket my-name speaker
28 channel message is-action)
29 (define (looks-like-me? str)
30 (or (equal? str my-name)
31 (equal? str (string-concatenate (list my-name ":")))))
32 (match (string-split message #\space)
33 (((? looks-like-me? _) action action-args ...)
36 (irc-format socket "PRIVMSG ~a :Yippie! *does a dance!*" channel))
37 ((or "hello" "hello!" "hello." "greetings" "greetings." "greetings!"
39 (irc-format socket "PRIVMSG ~a :Oh hi ~a!" channel speaker))
42 (irc-format socket "PRIVMSG ~a :*stupid puppy look*" channel))))
46 (format #t "~a emoted ~s in channel ~a\n"
47 speaker message channel))
49 (format #t "~a said ~s in channel ~a\n"
50 speaker message channel))))))
53 (make-irc-bot-cli (make-handle-line
54 #:handle-privmsg (wrap-apply handle-message))))