Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-exz committed Dec 20, 2024
1 parent fed65ed commit 4ec5ee8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
10 changes: 6 additions & 4 deletions bot/commands/action_create.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class ActionCreate
DESCRIPTION = 'Will create an answer from the bot for this keyword problem.'.freeze
EXAMPLE = 'Usage: `action create problem:NEWERROR action:What to do with this error`'.freeze
def self.call(client:, data:, match:)
action = Action.new(
problem: match["expression"][/problem:(.*) action:/, 1],
action: match["expression"][/ action:(.*)$/, 1],
problem: match['expression'][/problem:(.*) action:/, 1],
action: match['expression'][/ action:(.*)$/, 1],
channel: data.channel
)

if action.save
client.web_client.chat_postMessage(
channel: data.channel,
text: I18n.t("commands.action.created.text"),
text: I18n.t('commands.action.created.text'),
thread_ts: data.thread_ts || data.ts,
as_user: true
)
else
client.web_client.chat_postMessage(
channel: data.channel,
text: I18n.t("commands.action.failed.text"),
text: I18n.t('commands.action.failed.text'),
thread_ts: data.thread_ts || data.ts,
as_user: true
)
Expand Down
6 changes: 4 additions & 2 deletions bot/commands/action_delete.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class ActionDelete
DESCRIPTION = 'Will delete the answer from the bot for this keyword.'.freeze
EXAMPLE = 'Usage: `action delete problem:NEWERROR`'.freeze
def self.call(client:, data:, match:)
Action.where(
problem: match["expression"][/problem:(.*)/, 1],
problem: match['expression'][/problem:(.*)/, 1],
channel: data.channel
).delete_all

client.web_client.chat_postMessage(
channel: data.channel,
text: I18n.t("commands.action.deleted.text"),
text: I18n.t('commands.action.deleted.text'),
thread_ts: data.thread_ts || data.ts,
as_user: true
)
Expand Down
3 changes: 3 additions & 0 deletions bot/commands/git_commits.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class UserCommits

DESCRIPTION = 'Will display the last 10 commits of a user.'.freeze
EXAMPLE = 'Usage: `git commits @user`'.freeze
def self.call(client:, data:, match:)
message_processor = MessageProcessor.new
user_name = match['expression'][/<@(.+)>/, 1]
Expand Down
21 changes: 20 additions & 1 deletion bot/commands/help.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class Help

DESCRIPTION = "help"
EXAMPLE = "hoho"
def self.call(client:, data:)
help_text = generate_help_text
client.web_client.chat_postMessage(
channel: data.channel,
text: I18n.t("commands.help.text", version: Whoisondutytoday::Application::VERSION),
text: help_text,
thread_ts: data.thread_ts || data.ts,
as_user: true
)
end

def self.generate_help_text
commands = [
WhoIsOnDuty,
Help
]

help_text = "Here are the available commands:\n\n"
commands.each do |command|
help_text += "* #{command::DESCRIPTION}\n"
help_text += " #{command::EXAMPLE}\n\n"
end

help_text
end
end
end
end
25 changes: 1 addition & 24 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,8 @@ en:
text: |
Running version: %{version} | <https://github.com/mr-exz/whoisondutytoday|GitHub> | <https://github.com/mr-exz/whoisondutytoday/blob/master/CHANGELOG.md|Changelog>
Commands in channel:
-- `call duty person` - Will send an alert message to the duty person.
-- `i am on duty` - Will set you as the duty person in the channel.
-- `who is on duty?` - Will display the name of the duty person.
-- `channel reminder enabled` - Will enable reminders for unanswered messages in the channel.
-- `channel reminder disabled` - Will disable reminders for unanswered messages in the channel.
-- `duty create` - Will create a duty. Time should be defined in your local timezone, e.g., `duty create from 8:00 to 17:00`.
-- `duty update` - Will update a duty. Time should be defined in your local timezone, e.g., `duty update from 8:00 to 17:00`.
-- `duty delete` - Will delete a duty.
-- `duty sync with opsgenie schedule` - Will configure all duties in the channel with the schedule name from Opsgenie, e.g., `duty sync with opsgenie schedule My_Team_Schedule`.
-- `duty set opsgenie escalation` - Will configure all duties in the channel with the escalation name from Opsgenie, e.g., `duty set opsgenie escalation My_Team_Escalation`.
-- `answer set custom text` - Will configure custom text in answers from the bot, e.g., `answer set custom text nobody will help you, wait for next day`.
-- `answer delete custom text` - Will delete the custom text answer and use the default.
-- `answer enable hide reason` - Will hide the reason like `You asked at a non-working day.` Only your custom text will be displayed.
-- `answer disable hide reason` - Will show the reason like `You asked at a non-working day.`.
-- `checked` - Will mark the thread as checked.
-- `action create problem:NEWERROR action:What to do with this error` - Will create an answer from the bot for this keyword problem.
-- `action delete problem:NEWERROR` - Will delete the answer from the bot for this keyword.
-- `thread labels` - Will label the thread with any label. Use space as a separator, e.g., `thread labels label1 label2`.
-- `thread labels clean` - Will remove all labels from the thread where you write it.
-- `channel labels list` - Will display all labels in this channel.
-- `channel labels statistic` - Will show the label count in the channel for the last week.
-- `channel labels merge` - Will migrate existing threads in the channel from one label to another, e.g., `channel labels merge from:label1 to:label2`.
Commands in direct messages:
-- `my status *` - Will set any status when you cannot provide support in the channel. The bot will reply instead of you.
-- `my status work` - The bot will stop telling your status. Use it when you come back.
channel:
labels:
merged:
Expand Down

0 comments on commit 4ec5ee8

Please sign in to comment.