Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from Shopify/add-update-and-delete-to-api
Browse files Browse the repository at this point in the history
Add a update and delete methods to api and chat service
  • Loading branch information
RyanBrushett authored Jan 23, 2018
2 parents bf61d17 + 9f0f7a6 commit 2986875
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
21 changes: 21 additions & 0 deletions lib/lita/adapters/slack/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def send_attachments(room_or_user, attachments)
)
end

def open_dialog(dialog, trigger_id)
call_api(
"dialog.open",
dialog: MultiJson.dump(dialog),
trigger_id: trigger_id,
)
end

def send_messages(channel_id, messages)
call_api(
"chat.postMessage",
Expand All @@ -65,6 +73,19 @@ def send_messages(channel_id, messages)
)
end

def delete(channel, ts)
call_api("chat.delete", channel: channel, ts: ts)
end

def update_attachments(channel, ts, attachments)
call_api(
"chat.update",
channel: channel,
ts: ts,
attachments: MultiJson.dump(attachments.map(&:to_hash))
)
end

def set_topic(channel, topic)
call_api("channels.setTopic", channel: channel, topic: topic)
end
Expand Down
23 changes: 23 additions & 0 deletions lib/lita/adapters/slack/chat_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ def send_attachments(target, attachments)
api.send_attachments(target, Array(attachments))
end
alias_method :send_attachment, :send_attachments

# @param dialog The dialog to be shown to the user
# @param trigger_id The trigger id of a slash command request URL or interactive message
# @return [void]
def open_dialog(dialog, trigger_id)
api.open_dialog(dialog, trigger_id)
end

# @param channel The channel containing the message to be deleted
# @param ts The timestamp of the message
# @return [void]
def delete(channel, ts)
api.delete(channel, ts)
end

# @param channel The channel containing the message to be deleted
# @param ts The timestamp of the message
# @param attachments [Attachment, Array<Attachment>] An {Attachment} or array of
# {Attachment}s to send.
# @return [void]
def update_attachments(channel, ts, attachments)
api.update_attachments(channel, ts, Array(attachments))
end
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions lita-slack.gemspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Gem::Specification.new do |spec|
spec.name = "lita-slack"
spec.version = "1.8.0"
spec.authors = ["Ken J.", "Jimmy Cuadra"]
spec.email = ["kenjij@gmail.com", "jimmy@jimmycuadra.com"]
spec.authors = ["Ryan Brushett"]
spec.description = %q{Lita adapter for Slack.}
spec.summary = %q{Lita adapter for Slack.}
spec.homepage = "https://github.com/kenjij/lita-slack"
spec.homepage = "https://github.com/Shopify/lita-slack"
spec.license = "MIT"
spec.metadata = { "lita_plugin_type" => "adapter" }

Expand Down
4 changes: 4 additions & 0 deletions shipit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
deploy:
override:
- bundle exec rake build
- bundle exec package_cloud push shopify/gems pkg/*.gem

0 comments on commit 2986875

Please sign in to comment.