;;; License along with 8sync. If not, see <http://www.gnu.org/licenses/>.
(use-modules (8sync)
+ (8sync contrib irc)
(8sync systems irc)
(8sync repl)
(oop goops)
(define-class <my-irc-bot> (<irc-bot>))
-(define-method (handle-line (irc-bot <my-irc-bot>) message
- speaker channel line emote?)
+(define-method (handle-message (irc-bot <my-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>)
+ (= 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)
things to:
@example
-(define-method (handle-line (irc-bot <my-irc-bot>) message
- speaker channel line emote?)
+(define-method (handle-message (irc-bot <my-irc-bot>) message)
;; [... snip ...]
(define (respond respond-line)
(<- (actor-id irc-bot) 'send-line (pk 'channel channel)
(We can remove the pk now that we know what's going on.)
@example
-(define-method (handle-line (irc-bot <my-irc-bot>) message
- speaker channel line emote?)
+(define-method (handle-line (irc-bot <my-irc-bot>) message)
;; [... snip ...]
(define (respond respond-line)
(<- (actor-id irc-bot) 'send-line