Guest User

Untitled

a guest
Jan 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. (ql:quickload '(:cl-slack
  2. :event-emitter
  3. :websocket-driver
  4. :jonathan
  5. :cl-async
  6. )
  7. :silent t)
  8.  
  9. (defconstant +token+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
  10. (defconstant +channel+ "xxx")
  11. (defvar *client* (make-instance 'cl-slack.core:slack-client
  12. :token +token+))
  13.  
  14. (let ((url (getf (jonathan:parse (cl-slack.rtm:start *client* nil)) :|url|)))
  15. (format t url)
  16. (defparameter *slack-bot* (wsd:make-client url)))
  17.  
  18. (defun params (id type channel text)
  19. (jonathan:to-json (list :|id| id
  20. :|type| type
  21. :|channel| channel
  22. :|text| text)))
  23.  
  24. (wsd:on :message *slack-bot*
  25. (lambda (message)
  26. (let ((data (jonathan:parse message)))
  27. (format t "~A~%" data)
  28. (when (string= (getf data :|type|) "message")
  29. (wsd:send *slack-bot*
  30. (params 1
  31. "message"
  32. (getf data :|channel|)
  33. (getf data :|text|)))))))
  34.  
  35. (as:with-event-loop (:catch-app-errors t)
  36. (wsd:start-connection *slack-bot*))
Add Comment
Please, Sign In to add comment