diff options
author | Boutade <thegoofist@protonmail.com> | 2019-09-28 22:45:43 -0500 |
---|---|---|
committer | Boutade <thegoofist@protonmail.com> | 2019-09-28 22:45:43 -0500 |
commit | f50e97a59ea992e5475449763177690b4005506b (patch) | |
tree | 782f22e275d7c05bc43ab6bdd977322f50310d6c | |
parent | c34fc605de6bd9e41cf4ca964c9a9ae431e5ebf3 (diff) |
added readable-username function
-rw-r--r-- | examples/roshambot.lisp | 16 | ||||
-rw-r--r-- | package.lisp | 4 | ||||
-rw-r--r-- | utils.lisp | 7 |
3 files changed, 23 insertions, 4 deletions
diff --git a/examples/roshambot.lisp b/examples/roshambot.lisp index fcb3198..be870bb 100644 --- a/examples/roshambot.lisp +++ b/examples/roshambot.lisp @@ -94,8 +94,10 @@ (cancelled-by (roshambo-cancelled!? roshambo-match) (send-text-message bot (roshambo-match-room roshambo-match) "The match between ~a and ~a was canceled by ~a." - (roshambo-match-challenger roshambo-match) - (roshambo-match-challenged roshambo-match) + (readable-username + (roshambo-match-challenger roshambo-match)) + (readable-username + (roshambo-match-challenged roshambo-match)) cancelled-by) (kill-roshambo-match bot roshambo-match)) (win-list (roshambo-has-winner!? roshambo-match) @@ -103,10 +105,16 @@ (if (eql winner :draw) ; this is a draw move (send-text-message bot (roshambo-match-room roshambo-match) "It's a draw! Both ~a and ~a picked ~a." - win-move loser lose-move) + (readable-username win-move) + (readable-username loser) + lose-move) (send-text-message bot (roshambo-match-room roshambo-match) "~a's ~a beats ~a's ~a! ~a is the winner!~%" - winner win-move loser lose-move winner))) + (readable-username winner) + win-move + (readable-username loser) + lose-move + (readable-username winner)))) (kill-roshambo-match bot roshambo-match)))) diff --git a/package.lisp b/package.lisp index a498946..c88d8f6 100644 --- a/package.lisp +++ b/package.lisp @@ -11,6 +11,10 @@ #:getob #:def-json-wrap + ;; utilities + #:string->json-key + #:readable-username + ;; main class #:client #:homeserver @@ -2,3 +2,10 @@ (defun string->json-key (s) (read-from-string (format nil ":|~a|" s))) + +(defun readable-username (s) + (let ((stop-index (search ":" s))) + (if (and stop-index + (equal #\@ (aref s 0))) + (subseq s 1 stop-index) + s))) |