Closed serialhex closed 8 years ago
Thanks for opening the issue!
This project could use some serious love, I haven't touched it in a while. I didn't even realize the package wasn't functional. The rtm
module is missing the rtm-read
, rtm-send!
, and rtm-close!
functions. They were never exported from the module!
What's worse is that the wrapper I created is just the bare minimum around the slack RTM API. In order to make anything happen, you have to hand craft a message as a hasheq, then pass it to rtm-send
. Very bare bones.
In the long run, I'd love to make a higher level interface to make writing simple bots and things much easier - most people won't need to work directly with the rtm
functions. In the meantime, that's all I got.
Tonight, I will make sure I get around to fixing the package, so you can at least use what's there, and I'll write an example showing you how to use the rtm
functions.
Sweet! I forked the repo, and eventually figured out what needed to get done, but having an example & some docs would help.
If there is anything in particular you would like help with let me know! I'm not intimately familiar with Racket, but I am with Common Lisp, so there is a bit of a re-learning curve & just figuring out how things are done or organized. I don't want to make your code a mess cause I'm new at Racket (I know they're 99% the same, it's just that 1% I'm worried about)
Thanks again!
I pushed a change to export those functions. Below is a "simple" hello world example. As you can tell, it's quite verbose, but workable. I also changed rtm-start to return the provided metadata about group slack sends on a successful connect. You need this data to look up user ids and channel ids.
(require slack-api)
; Create a rtm connection and receive a hasheq of metadata from slack
(define-values (rtm metadata)
(rtm-start "APIKEY"))
; Pulls a list of hashes (one for each channel) from the metadata
(define chans (hash-ref metadata 'channels))
; Filter the list for the channel we want ("botspam" in this example)
(define botspam
(first
(filter (lambda (x) (string=? (hash-ref x 'name)
"botspam"))
chans)))
; Get the "botspam" slack channel id
(define id (hash-ref botspam 'id))
; Create and send a message using the rtm object
(define message (hasheq 'type "message"
'channel id
'text "hello world"))
(rtm-send! rtm message)
Defining every little piece like that is unnecessary, and you could probably do better, but it does make it easy to inspect in a REPL.
Good luck! Please let me know if you have anymore questions or suggestions.
hey i just noticed, you may have put your api-key in the previous post, you may want to edit that out & gen a new one...
I havn't had a chance to play with the new stuff yet, but i will probably this pm. Thanks for the update!!
Thanks for the heads up!
Just an fyi: i've got a bot up & running. it doesn't do anything spiffy, it just cusses using a shakespeare insult generator. Thank you for the api!! I really appreciate it! :smiley_cat:
Alright, i didn't really want to create an issue, but thats the easiest way to contact you. Anyway, I'm trying to set up a slack bot, and i'm kind of stuck. I can auth & it says my bot is in the room but then I can't do anything.
I'm guessing the result from calling
rtm-start "api-key"
is my token? And I use that for calling all the functions...? I haven't made a bot in any language, so I'm totally lost (and losing my hacker cred if i can't make a simple chatbot :stuck_out_tongue_closed_eyes: )Let me know! Thanks!