1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- (use-modules (8sync) ; 8sync's agenda and actors
- (8sync systems irc) ; the irc bot subsystem
- (oop goops) ; 8sync's actors use GOOPS
- (ice-9 format) ; basic string formatting
- (ice-9 match)) ; pattern matching
- (define-class <my-irc-bot> (<irc-bot>))
- (define-method (handle-line (irc-bot <my-irc-bot>) message
- speaker channel line emote?)
- (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 ":")))))
- (define (respond respond-line)
- (<- (actor-id irc-bot) 'send-line channel
- respond-line))
- (if [looks-like-me? (car (string-split line #\space))]
- [match (string-split line #\space)
- (((? looks-like-me? _) action action-args ...)
- (match action
- ;; The classic botsnack!
- ("botsnack"
- (respond "Yippie! *does a dance!*"))
- (_
- (respond "*stupid puppy look*"))))]
- [cond [(or (member "linux" (string-split line #\space))
- (member "Linux" (string-split line #\space)))
- (respond "I'd just like to interject for moment. What you're refering to as Linux, is in fact, GNU/Linux.")]
- [(and (member "open" (string-split line #\space))
- (member "source" (string-split line #\space)))
- (respond "I think you meant Free Software https://www.gnu.org/philosophy/open-source-misses-the-point.html not 'open source'")]
- [(or (equal? "noordinaryspider" speaker)
- (equal "noordinaryspider[m]" speaker))
- (respond "Please do not spam #lgn kid noordinaryspider")]]))
- (define* (run-bot #:key (username "examplebot")
- (server "irc.freenode.net")
- (channels '("##saratestlab")))
- (define hive (make-hive))
- (define irc-bot
- (pk 'bootstrapped
- (bootstrap-actor hive <my-irc-bot>
- #:username username
- #:server server
- #:channels channels)))
- (run-hive hive '()))
- (run-bot #:username "Sara") ; be creative!
|