llimllib / limbo

A simple, clean, easy to modify Slack chatbot
MIT License
402 stars 160 forks source link

Which function do I use for sending intermediate messages? #126

Closed topher200 closed 6 years ago

topher200 commented 6 years ago

My question is in two parts:

  1. I want to send a message while I'm "processing" the user's request. So I want the convo to be

    User: bot do thing
    Bot: message 1 - doing thing!
    Bot: message 2 - did thing!

    What is the best way to send "message 1"? My best two candidates are slack.rtm_send_message and slack.post_message. I don't see any examples in the existing plugins of sending an intermediate message. If you had to send an intermediate message, which would you use?

  2. If the answer to question 1 is slack.rtm_send_message, we should implement that function in FakeSlack so I can call it in tests. If the answer is slack.post_message, then we don't need to bother.

Looking at the two functions, it seems like slack.post_message takes more args and is possibly more configurable. limbo.py also mentions something about using it to "sending messages from the loop hook". Based on the answers to all these questions, I think I'll add some documentation around exactly what those functions do, what they should be used for, and what makes them different.

llimllib commented 6 years ago

I would use server.slack.post_message; there's an example in the github plugin: https://github.com/llimllib/limbo/blob/a6d8bc904ea100fa0295c370455a1f5a07dc681d/limbo/plugins/github.py#L333-L339

llimllib commented 6 years ago

(closed by accident)

topher200 commented 6 years ago

Thanks! Doing research on this question led me to the slack docs; I didn't realize that postMessage and RTM Message came straight from their lingo. For anyone else looking to know the difference between the two, I'd highlight these docs:

I'm trying to enumerate the differences between the two APIs i.r.t. Limbo. Does this look accurate? Anything you'd add?

Action slack.rtm_send_message slack.post_message
Messages look like they're sent from your specific Bot user Handled automatically Requires kwarg: as_user=server.slack.username. Otherwise, the messages look like they came from a default, generic Bot user
Complex messages The RTM API only supports posting simple messages formatted using Slack's default message formatting mode. It does not support attachments or other message formatting modes Provides more complex messages
llimllib commented 6 years ago

Nope, that looks completely accurate 💯