Last active
March 18, 2020 03:08
-
-
Save judah-caruso/40d5044d2cc505b788556fe57979f846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq cmd-char ?!) ;; the leader for our commands '!' | |
(defun show-commands () | |
(print "ran !commands")) | |
;; take a string input (what the twitch user types) | |
;; and look for a '!' + one of our commands. | |
(defun run-command (input) | |
;; get the 0th character from our string and compare it to '!' | |
(if (eq cmd-char (aref input 0)) | |
;; if valid, compare the rest of our string to a command | |
(let ((cmd (substring input 1))) | |
(cond ;; dispatch the passing command or fail | |
((string= cmd "commands") (show-commands)) | |
((string= cmd "things") (print "found things")) | |
((string= cmd "other") (print "found other")) | |
;; if everything above fails, we have an invalid command | |
(t (concat "Invalid command: " input)) | |
)) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment