Skip to content

Instantly share code, notes, and snippets.

@Otann
Created July 26, 2016 09:49
Show Gist options
  • Save Otann/f6c01e321fa972cc0b3c772be58eb3f1 to your computer and use it in GitHub Desktop.
Save Otann/f6c01e321fa972cc0b3c772be58eb3f1 to your computer and use it in GitHub Desktop.
Multiple bots passing bot-specific information to a handler
(defhandler client-handler
(command "start" (handle-start message))
(command "stop" (handle-stop message))
(message message (handle-msg message)))
; means
(def client-handler (handlers (command "start" (handle-start message))
(command "stop" (handle-stop message))
(message message (handle-msg message))))
; so you can do something like this
(defn make-handler [bot-id]
(handlers (command "start" (handle-start bot-id message))
(command "stop" (handle-stop bot-id message))
(message message (handle-msg bot-id message))))
; and then
(def channel1
(pol/start token1 (make-handler client-handler :bot-1)))
(def channel2
(pol/start token1 (make-handler client-handler :bot-2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment