aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Laprade <jesselaprade@gmail.com>2021-03-22 16:31:09 -0400
committerJesse Laprade <jesselaprade@gmail.com>2021-03-22 16:31:09 -0400
commite1d5be41073788faf7deb60250773885feea73db (patch)
treed0b041d2180917a7ce8cc5f87a303cd304f21b4c
parent3b0dc64812588d2752524a0790bc980e86578026 (diff)
downloadruth-e1d5be41073788faf7deb60250773885feea73db.tar.gz
ruth-e1d5be41073788faf7deb60250773885feea73db.tar.bz2
ruth-e1d5be41073788faf7deb60250773885feea73db.zip
wrote channel and message getters
-rw-r--r--src/ruth.rkt38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/ruth.rkt b/src/ruth.rkt
index b514296..4d8944c 100644
--- a/src/ruth.rkt
+++ b/src/ruth.rkt
@@ -173,36 +173,36 @@
(send-message channel "fuuuuuuuuuuuuuccccccccccccccccccccccccckkkkkkkkkkk")
'hangout)))
+;; Split message should look something like the following:
+;; nick username channel message
+;; :m455!m455@localhost PRIVMSG #tildetown :hmmm let me open up town's tmux
(define (get-nickname split-message)
- (let* ([nickname-block (list-ref split-message 0)] ;; :nickname!username@whatever
- [colon-removed (substring nickname-block 1)] ;; nickname!username@whatever
- [nickname (string-trim colon-removed #px"(!.+)$")])
- nickname))
+ (let* ([nickname-block (list-ref split-message 0)]
+ [colon-removed (substring nickname-block 1)])
+ (string-trim colon-removed #px"(!.+)$")))
(define (get-username split-message)
- (let* ([username-block (list-ref split-message 0)] ;; :username!username@whatever
- [username-matches (regexp-match #rx"![~]?(.+)@" username-block)] ;; '("!username@" "username")
- [username (list-ref username-matches 1)])
- username))
+ (let* ([username-block (list-ref split-message 0)]
+ [username-matches (regexp-match #rx"![~]?(.+)@" username-block)])
+ (list-ref username-matches 1)))
(define (get-channel split-message)
- ;; TODO
- )
+ (list-ref split-message 2))
+;; TODO: Finish this up, and then change how the message matching
+; behaviour works below
(define (get-message split-message)
- ;; TODO
- )
+ (let* ([message-first-word (list-ref split-message 3)]
+ [colon-removed (substring message-first-word 1)])
+ (cons colon-removed (list-tail split-message 4))))
-;; This accepts a server string that looks something like:
-;; nick username channel message
-;; :m455!m455@localhost PRIVMSG #tildetown :hmmm let me open up town's tmux
(define (commands-listen server-data-string)
(let ([split-message (string-split message)])
(when (equal? (list-ref split-message 1) "PRIVMSG")
- (let* ([nickname (get-nickname split-message)];;DONE
- [username (get-username split-message)];;DONE
- [channel (get-channel split-message)] ;;TODO
- [message (get-message split-message)]);;TODO
+ (let* ([nickname (get-nickname split-message)]
+ [username (get-username split-message)]
+ [channel (get-channel split-message)]
+ [message (get-message split-message)])
(match message
;; 2-item matches
[(list (== command-water)