6/21/2023 0 Comments Nodejs irc rss bot![]() ![]() (respond (format "Hello, ~a!" (hash-ref data "sender")))] (define args (string-split (hash-ref data "message"))) ![]() (define connection (ircbot-connect #:nick "racketbot" In case this makes it more clear, here is an extremely simple bot implemented using the above module. (callback (hash "oldnick" (first prefix-match) (callback (hash "nick" (first prefix-match) (unbox (ircbot-connection-trigger-handlers connection)))) (when (member trigger (ircbot-connection-triggers connection)) (define reconstructed (string-join (rest args))) (unbox (ircbot-connection-chat-handlers connection))) (unbox (ircbot-connection-action-handlers connection))) (unbox (ircbot-connection-message-handlers connection))) (λ (response) (respond connection sender recipient response)))) (define prefix-match (regexp-match #rx"^ " prefix)) (irc-connection-incoming (ircbot-connection-connection connection)))) (map (λ (el) (el (hash "text" response))) (unbox (ircbot-connection-self-handlers connection))))) (if (channel? recipient) recipient sender) ![]() (irc-send-message (ircbot-connection-connection connection) (define (respond connection sender recipient response) (append (unbox (#,(format-id #'name #:source #'name (set-box! (#,(format-id #'name #:source #'name #`(define (#,(format-id #'name #:source #'name (define-syntax (define-ircbot-listener stx) (irc-send-message (ircbot-connection-connection connection) channel message)))) (irc-send-command (ircbot-connection-connection connection)Ĭhannel (format ":\u0001ACTION ~a\u0001" message)) (when (equal? (string-contains message "/me ") 0) (ircbot-connection server nick username realname channels triggers pmtrigger (irc-connect server port nick username realname)) Self-handlers self-action-handlers join-handlers part-handlers (struct ircbot-connection (server nick username realname channels triggers pmtriggerĪction-handlers chat-handlers trigger-handlers message-handlers I'm not looking for anything extremely specific, but I would like to know if I'm violating any major conventions of the language in any obvious ways. I know it's rather long and probably fairly unreadable, and for that I apologize. My module simply provides some utility functions to make it easier to implement IRC bots. The Racket version is built atop the Racket irc package, so the low-level code is handled by that. To help myself learn Racket, I ported a simple JavaScript ircbot module I wrote for Node.js to Racket. ![]()
0 Comments
Leave a Reply. |