Skip to content
This repository was archived by the owner on Nov 29, 2017. It is now read-only.
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/models/hackbot/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Dispatcher
Hackbot::Interactions::Gifs,
Hackbot::Interactions::Help,
Hackbot::Interactions::Lookup,
Hackbot::Interactions::RemoveJoinMessage,
Hackbot::Interactions::SetPoc,
Hackbot::Interactions::Sql,
Hackbot::Interactions::Stats,
Expand Down
13 changes: 13 additions & 0 deletions app/models/hackbot/interactions/remove_join_message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Hackbot
module Interactions
class RemoveJoinMessage < TextConversation
def should_start?
super && event[:subtype] == 'channel_join'
end

def start
del_msg(event[:channel], event[:ts])
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/hackbot/slack_interaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def send_msg(channel, msg)
::SlackClient::Chat.send_msg(channel, nil, access_token, opts)
end

def del_msg(channel, ts)
::SlackClient::Chat.delete(channel, ts, access_token)
end

def attach(channel, *attachments)
send_msg(channel, attachments: attachments)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/slack_client/chat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ def self.send_msg(channel, text, access_token, extra_params = {})

SlackClient.rpc('chat.postMessage', access_token, extra_params)
end

def self.delete(channel, ts, access_token)
SlackClient.rpc('chat.delete', access_token, channel: channel, ts: ts)
end
end
end