-
Notifications
You must be signed in to change notification settings - Fork 1
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
7 changed files
with
200 additions
and
89 deletions.
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,48 @@ | ||
module WhoIsOnDutyTodaySlackBotModule | ||
module Commands | ||
class ActionShowAction | ||
DESCRIPTION = 'Will display action for mentioned problem'.freeze | ||
EXAMPLE = 'Usage: `action show action for problem:MyProblem`'.freeze | ||
def self.call(client:, data:, match:) | ||
problem_text = match['expression'][/problem:(.*)$/, 1] | ||
problems = Action.where('channel = ? AND problem LIKE ?', data.channel, "%#{problem_text}%") | ||
|
||
if problems.any? | ||
attachments = problems.map do |problem| | ||
{ | ||
fallback: "Problem: #{problem.problem}", | ||
color: '#36a64f', | ||
fields: [ | ||
{ | ||
title: 'Problem', | ||
value: problem.problem, | ||
short: false | ||
}, | ||
{ | ||
title: 'Action', | ||
value: problem.action, | ||
short: false | ||
} | ||
] | ||
} | ||
end | ||
|
||
client.web_client.chat_postMessage( | ||
channel: data.channel, | ||
text: 'Here are the problems and their actions:', | ||
attachments: attachments, | ||
thread_ts: data.thread_ts || data.ts, | ||
as_user: true | ||
) | ||
else | ||
client.web_client.chat_postMessage( | ||
channel: data.channel, | ||
text: 'No problems with actions found for this channel.', | ||
thread_ts: data.thread_ts || data.ts, | ||
as_user: true | ||
) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module WhoIsOnDutyTodaySlackBotModule | ||
module Commands | ||
class ActionShowProblems | ||
DESCRIPTION = 'Will display problems for this channel'.freeze | ||
EXAMPLE = 'Usage: `action show problems`'.freeze | ||
def self.call(client:, data:) | ||
problems = Action.where(channel: data.channel).where.not(action: nil) | ||
|
||
if problems.any? | ||
attachments = problems.map do |problem| | ||
{ | ||
fallback: "Problem: #{problem.problem}", | ||
color: '#36a64f', | ||
fields: [ | ||
{ | ||
title: 'Problem', | ||
value: problem.problem, | ||
short: false | ||
}, | ||
{ | ||
title: 'Solution', | ||
value: problem.action, | ||
short: false | ||
} | ||
] | ||
} | ||
end | ||
|
||
client.web_client.chat_postMessage( | ||
channel: data.channel, | ||
text: 'Here are the problems and their solutions:', | ||
attachments: attachments, | ||
thread_ts: data.thread_ts || data.ts, | ||
as_user: true | ||
) | ||
else | ||
client.web_client.chat_postMessage( | ||
channel: data.channel, | ||
text: 'No problems with solutions found for this channel.', | ||
thread_ts: data.thread_ts || data.ts, | ||
as_user: true | ||
) | ||
end | ||
end | ||
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
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