Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for chat.postMessage API method #15

Merged
merged 1 commit into from
Feb 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/channel.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ class Channel
m = new Message @_client, {text: text}
@sendMessage m

postMessage: (data) ->
params = data
params.channel = @id
if data.attachments
params.attachments = JSON.stringify(data.attachments)

@_client.logger.debug data
@_client.logger.debug params
@_client._apiCall "chat.postMessage", params, @_onPostMessage

_onPostMessage: (data) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought...

There are a bunch of these _on{{ApiMethod}} methods that just call the logger. Not really bad but might be easier to just pass around the logger directly instead of a bunch of different methods that wrap it (unless there's some other purpose I'm missing).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fair point - I was just copying the existing pattern. I'm open to other approaches here!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea you definitely didn't start it here. Not a big deal, just something I noticed.

@_client.logger.debug data

sendMessage: (message) ->
message.channel = @id
@_client._send(message)
Expand Down