Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-exz committed Nov 1, 2023
1 parent bdc0861 commit f526db1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog
## 0.10.1
### Improvements
- Deleting no needed code
- Added `channel labels merge`

## 0.10.0
Expand Down
8 changes: 4 additions & 4 deletions bot/commands/channel_labels_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module WhoIsOnDutyTodaySlackBotModule
module Commands
class ChannelLabelsMerge
def self.call(client:, data:, match:)
label_from = match["expression"][/from:(.*) action:/, 1]
label_from = match["expression"][/from:(.*) to:/, 1]
label_to = match["expression"][/ to:(.*)$/, 1]
label_to_id = Label.where(label: label_to).ids[0]

if (label_from != nil?) || (label_to_id != nil?)
m = SlackThreadLabel.joins(:label, :slack_thread).where(slack_thread: {channel_id: data.channel}, label: {label: label_from})
m.update_all(label_id: label_to_id)
message = "label_from label_to merged"
records_affected=m.update_all(label_id: label_to_id)
message = I18n.t("commands.channel.labels.merged.success.text",label_from:label_from,label_to:label_to,records_affected:records_affected)
else
message = "Sorry, label_from or label_to not found, merge not possible."
message = I18n.t("commands.channel.labels.merged.error.text",label_from:label_from,label_to:label_to)
end
client.web_client.chat_postMessage(
channel: data.channel,
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ en:
-- `my status *` - set any status when you cannot provide support in channel, bot will reply instead of you.
-- `my status work` - bot will stop telling your status, use it when you came back.
channel:
labels:
merged:
success:
text: "Labels merged %{label_from} -> %{label_to} records affected %{records_count}"
error:
text: "Merge %{label_from} -> %{label_to} failed, check label names"
reminder:
enabled:
text: "Reminder in channel successfully enabled."
Expand Down
7 changes: 7 additions & 0 deletions config/locales/hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ hr:
action:
failed:
text: ""
channel:
labels:
merged:
error:
text: ""
success:
text: ""
reply:
non-working-time:
subject: "Nešto se dogodilo"
Expand Down
7 changes: 7 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ ru:
action:
failed:
text: ""
channel:
labels:
merged:
error:
text: ""
success:
text: ""
reply:
non-working-time:
subject: "Что то случилось"
Expand Down

0 comments on commit f526db1

Please sign in to comment.