Created
July 26, 2016 09:49
-
-
Save Otann/f6c01e321fa972cc0b3c772be58eb3f1 to your computer and use it in GitHub Desktop.
Multiple bots passing bot-specific information to a handler
This file contains 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
(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