-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class SlackSmartBot | ||
def delete(channel, ts) | ||
result = true | ||
begin | ||
resp = client.web_client.chat_delete(channel: channel, as_user: true, ts: ts) | ||
result = resp.ok.to_s == 'true' | ||
rescue Exception => exc | ||
result = false | ||
@logger.fatal exc.inspect | ||
end | ||
return result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
lib/slack/smart-bot/commands/on_bot/admin_master/delete_message.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class SlackSmartBot | ||
|
||
# helpadmin: ---------------------------------------------- | ||
# helpadmin: `delete message URL` | ||
# helpadmin: It will delete the SmartBot message supplied | ||
# helpadmin: You can use this command only if you are a Master admin user and if you are in a private conversation with the bot | ||
# helpadmin: | ||
def delete_message(from, typem, url) | ||
save_stats(__method__) | ||
channel, ts = url.scan(/\/archives\/(\w+)\/(\w\d+)/)[0] | ||
if config.masters.include?(from) and typem==:on_dm and !channel.nil? #master admin user | ||
ts = "#{ts[0..-7]}.#{ts[-6..-1]}" | ||
succ = delete(channel, ts) | ||
if succ | ||
react :heavy_check_mark | ||
else | ||
react :x | ||
end | ||
else | ||
respond "Only master admin users on a private conversation with the SmartBot can delete SmartBot messages" | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters