Skip to content

Commit

Permalink
add refactoring fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-exz committed Oct 3, 2023
1 parent 2881ca7 commit e697f6c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Added `allow list` to perform call on duty person [#153](/../../issues/153)
- Added Jira integration to create tasks from threads [#13](/../../issues/13)
- Added option to set 2 custom answers, working and non working time [#154](/../../issues/154)
- Added tagging threads by label for future statistics
- Added release notes announces
- Updated dependencies
- Removed vagrant files
Expand Down
2 changes: 0 additions & 2 deletions bot/commands/answer_set_custom_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ def self.call(client:,data:,match:)
answer.channel_id = data.channel

if answer.save

client.web_client.chat_postMessage(
channel: data.channel,
text: I18n.t('commands.answer.created.text'),
thread_ts: data.thread_ts || data.ts,
as_user: true
)

client.web_client.chat_postMessage(
channel: data.channel,
text: custom_text,
Expand Down
1 change: 0 additions & 1 deletion bot/commands/create_duty_for_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def self.set_user_on_duty(data:, client:, slack_user_id:)
thread_ts: data.thread_ts || data.ts
)
end

end
end
end
10 changes: 10 additions & 0 deletions bot/commands/duty_create.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class DutyCreate
def self.i_am_on_duty(data:, client:)
Duty.where(channel_id: data.channel).where(user_id: data.user).update_all(enabled: true)
Duty.where(channel_id: data.channel).where.not(user_id: data.user).update_all(enabled: false)
client.say(
channel: data.channel,
text: I18n.t('commands.duty.enabled.text'),
thread_ts: data.thread_ts || data.ts
)
end

def self.call(client:,data:,match:)
message_processor = MessageProcessor.new
slack_web_client = Slack::Web::Client.new
Expand Down
2 changes: 1 addition & 1 deletion bot/commands/duty_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.call(client:,data:,match:)
text: I18n.t('commands.duty.updated.text', fH: duty.duty_from.hour, fM: duty.duty_from.min, tH: duty.duty_to.hour, tM: duty.duty_to.min, status: duty.enabled),
thread_ts: data.thread_ts || data.ts
)
i_am_on_duty(data: data, client: client)
DutyCreate::i_am_on_duty(data: data, client: client)
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions bot/commands/other.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.call(client:,data:,match:)
end

# don't reply on duty person messages
#return if data.user == duty.user.slack_user_id
return if data.user == duty.user.slack_user_id

# Answer if it is known problem
if data != nil and match != nil
Expand Down Expand Up @@ -52,7 +52,6 @@ def self.call(client:,data:,match:)
end

def self.reply_in_not_working_time (client, reason, data, answer)

if answer.nil?
text = I18n.t('reply.non-working-time.text', name: client.self.name)
else
Expand Down
4 changes: 4 additions & 0 deletions bot/whoisondutytodayslackbot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require 'date'
require 'json'
require_relative 'commands/main'
require_relative 'notify'
require_relative 'message_processor'


class WhoIsOnDutyTodaySlackBot < SlackRubyBot::Bot
SlackRubyBot::Client.logger.level = Logger::WARN
Expand Down

0 comments on commit e697f6c

Please sign in to comment.