Skip to content

Instantly share code, notes, and snippets.

@judah-caruso
Last active March 18, 2020 03:08
Show Gist options
  • Save judah-caruso/40d5044d2cc505b788556fe57979f846 to your computer and use it in GitHub Desktop.
Save judah-caruso/40d5044d2cc505b788556fe57979f846 to your computer and use it in GitHub Desktop.
(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