Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ql:quickload '(:cl-slack
- :event-emitter
- :websocket-driver
- :jonathan
- :cl-async
- )
- :silent t)
- (defconstant +token+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
- (defconstant +channel+ "xxx")
- (defvar *client* (make-instance 'cl-slack.core:slack-client
- :token +token+))
- (let ((url (getf (jonathan:parse (cl-slack.rtm:start *client* nil)) :|url|)))
- (format t url)
- (defparameter *slack-bot* (wsd:make-client url)))
- (defun params (id type channel text)
- (jonathan:to-json (list :|id| id
- :|type| type
- :|channel| channel
- :|text| text)))
- (wsd:on :message *slack-bot*
- (lambda (message)
- (let ((data (jonathan:parse message)))
- (format t "~A~%" data)
- (when (string= (getf data :|type|) "message")
- (wsd:send *slack-bot*
- (params 1
- "message"
- (getf data :|channel|)
- (getf data :|text|)))))))
- (as:with-event-loop (:catch-app-errors t)
- (wsd:start-connection *slack-bot*))
Add Comment
Please, Sign In to add comment