Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.19.0 #197

Merged
merged 10 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Changelog
## 0.19.0
### Improvements
- Improved help description
- Updated documentation
- Code refactoring

## 0.18.3
### Bugfixes
- Reminder fixes
Expand Down
54 changes: 16 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,28 @@
# Slack bot Whoisondutytoday

## Description
This bot allow you configure working time in Slack channels.\
And if somebody will write at non working hours, bot will reply on message,\
with escalation option.

This is a Slack bot designed to manage and interact with users on support channels. \
It provides various commands to:
* Call the duty person.
* Show and update user on support statuses where it absent.
* Manage duty schedules (create, update, delete, sync with Opsgenie).
* Enable or disable channel-specific features like reminders, auto-answer, and tagging.
* Handle custom text for answers.
* Manage actions and show related problems.
* Clean and display thread labels.
* Show statistics and manage channel labels.
* Display user commits from Bitbucket.
* Remind about threads without replies.

## Links
* [Changelog](./CHANGELOG.md)
* [Docker](https://hub.docker.com/r/mrexz/whoisondutytoday)
* ![Build](https://github.com/mr-exz/whoisondutytoday/actions/workflows/docker-build.yml/badge.svg)
* ![Known Vulnerabilities](https://snyk.io/test/github/mr-exz/whoisondutytoday/badge.svg)


## Features
- Call duty person over Opsgenie service.
- User can enable themselves in channel as a duty person.
- Users in channel can ask bot who is on duty?
- User can tell to bot create/update/delete his (user) duty schedule in channel.
- User can set own status lunch/work/holidays.
- In non working time bot will reply on all messages in channel with option escalate it.
- Bot have internal Web UI: 127.0.0.1:3000.
- Web page list of duties in channels with delete option.
- Web page list of users.
- Web page list of replied messages.

## Bot commands
```
Commands in channel:
-- call duty person - will send alert message to duty person.
-- i am on duty - will set you as duty person in channel.
-- who is on duty? - will display name of duty persion.
-- channel reminder enabled - will enable reminder for not answered messages in channel.
-- channel reminder disabled - will disable reminder for not answered messages in channel.
-- duty create - will create duty, example duty create from 8:00 to 17:00.
-- duty update - will update duty, example duty update from 8:00 to 17:00.
-- duty delete - will delete duty.
-- duty sync with opsgenie schedule - will configure all duties in channel with schedule name from Opsgenie, example duty sync with opsgenie schedule My_Team_Schedule.
-- duty set opsgenie escalation - will configure all duties in channel with escalation name from Opsgenie, example duty set opsgenie escalation My_Team_Escalation.
-- answer set custom text - configure custom text in answers from bot, example answer set custom text nobody will help you, wait for next day.
-- answer delete custom text - delete custom text answer, use default.
Commands in dirrect messages:
-- my status lunch - set status on lunch.
-- my status work - set status on duty.
-- my status holidays - set status on holidays.
@bot help
```

## How to start
Expand All @@ -52,13 +33,10 @@ cd ./whoisondutytoday
mkdir -p /opt/whoisondutytoday/db/data
```

Copy file and define valid Slack API API Token. Create bot [here](https://slack.com/intl/en-hr/help/articles/115005265703-create-a-bot-for-your-workspace).
Copy file and define variables. Create bot [here](https://slack.com/intl/en-hr/help/articles/115005265703-create-a-bot-for-your-workspace).

```bash
cp ./production.env.example ./production.env
```

```bash
docker-compose build
docker-compose up
```
Expand Down
2 changes: 1 addition & 1 deletion bot/commands/answer_delete_custom_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module WhoIsOnDutyTodaySlackBotModule
module Commands
class AnswerDeleteCustomText
DESCRIPTION = 'Will delete all custom text in channel.'.freeze
EXAMPLE = 'Usage: `answer delete custom text`'.freeze
EXAMPLE = '`answer delete custom text`'.freeze
def self.call(client:, data:)
Answer.where(channel_id: data.channel).delete_all

Expand Down
2 changes: 1 addition & 1 deletion bot/commands/answer_set_custom_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module WhoIsOnDutyTodaySlackBotModule
module Commands
class AnswerSetCustomText
DESCRIPTION = 'Will configure default answer in channel. type:non_working_time/working_time'.freeze
EXAMPLE = '`cibot answer set custom text type:<time type> text:<custom text>` example: `cibot answer set custom text type:non_working_time text:This is the custom text for non working hours.`'.freeze
EXAMPLE = '`answer set custom text type:<time type> text:<custom text>` example: `cibot answer set custom text type:non_working_time text:This is the custom text for non working hours.`'.freeze
def self.call(client:, data:, match:)
expression = match['expression']

Expand Down
31 changes: 31 additions & 0 deletions bot/commands/channel_auto_answer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class ChannelAutoAnswer < SlackRubyBot::Commands::Base
DESCRIPTION = 'Bot will answer on any message in channel at working time'.freeze
EXAMPLE = 'channel auto_answer_enabled <boolean> example `channel auto_answer_enabled true`'.freeze

def self.call(client:, data:, match:)
value = match['expression']

unless %w[true false].include?(value)
client.say(
channel: data.channel,
text: "Invalid value for auto_answer_enabled. Please use 'true' or 'false'.",
thread_ts: data.thread_ts || data.ts
)
return
end

channel = Channel.find_or_initialize_by(slack_channel_id: data.channel)
channel.update(auto_answer_enabled: value)
channel.save

client.say(
channel: data.channel,
text: "Channel auto_answer_enabled has been set to '#{value}'.",
thread_ts: data.thread_ts || data.ts
)
end
end
end
end
19 changes: 0 additions & 19 deletions bot/commands/channel_auto_answer_disable.rb

This file was deleted.

19 changes: 0 additions & 19 deletions bot/commands/channel_auto_answer_enable.rb

This file was deleted.

31 changes: 31 additions & 0 deletions bot/commands/channel_reminder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class ChannelReminder < SlackRubyBot::Commands::Base
DESCRIPTION = 'Enable or disable channel reminder feature. Bot will remind you about threads without your response'.freeze
EXAMPLE = '`channel reminder_enabled <boolean>` example `channel reminder_enabled true`'.freeze

def self.call(client:, data:, match:)
value = match['expression']

unless %w[true false].include?(value)
client.say(
channel: data.channel,
text: "Invalid value for reminder_enabled. Please use 'true' or 'false'.",
thread_ts: data.thread_ts || data.ts
)
return
end

channel = Channel.find_or_initialize_by(slack_channel_id: data.channel)
channel.update(reminder_enabled: value)
channel.save

client.say(
channel: data.channel,
text: "Channel reminder_enabled has been set to '#{value}'.",
thread_ts: data.thread_ts || data.ts
)
end
end
end
end
19 changes: 0 additions & 19 deletions bot/commands/channel_reminder_disabled.rb

This file was deleted.

19 changes: 0 additions & 19 deletions bot/commands/channel_reminder_enabled.rb

This file was deleted.

32 changes: 32 additions & 0 deletions bot/commands/channel_tag_reporter_in_thread.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module WhoIsOnDutyTodaySlackBotModule
module Commands
class ChannelTagReporterInThread < SlackRubyBot::Commands::Base

DESCRIPTION = 'Enable or disable tagging the reporter in the thread.'.freeze
EXAMPLE = '`channel tag_reporter_enabled <boolean>` example `channel tag_reporter_enabled true`'.freeze

def self.call(client:, data:, match:)
value = match['expression']

unless %w[true false].include?(value)
client.say(
channel: data.channel,
text: "Invalid value for tag_reporter_enabled. Please use 'true' or 'false'.",
thread_ts: data.thread_ts || data.ts
)
return
end

channel = Channel.find_or_initialize_by(slack_channel_id: data.channel)
channel.update(tag_reporter_enabled: value)
channel.save

client.say(
channel: data.channel,
text: "Channel tag_reporter_enabled has been set to '#{value}'.",
thread_ts: data.thread_ts || data.ts
)
end
end
end
end
19 changes: 0 additions & 19 deletions bot/commands/channel_tag_reporter_in_thread_disable.rb

This file was deleted.

19 changes: 0 additions & 19 deletions bot/commands/channel_tag_reporter_in_thread_enable.rb

This file was deleted.

2 changes: 1 addition & 1 deletion bot/commands/duty_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module WhoIsOnDutyTodaySlackBotModule
module Commands
class DutyCreate
DESCRIPTION = 'Will create a duty. Time should be defined in your local timezone.'.freeze
EXAMPLE = 'Usage: `duty create from 8:00 to 17:00`'.freeze
EXAMPLE = '`duty create from <from time> to <to time>` example: `duty create from 8:00 to 17:00`'.freeze
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)
Expand Down
11 changes: 4 additions & 7 deletions bot/commands/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ def self.generate_help_text
Checked,
DutyCreate,
CreateDutyForUser,
ChannelReminderEnabled,
ChannelReminderDisabled,
ChannelAutoAnswerEnable,
ChannelAutoAnswerDisable,
ChannelTagReporterInThreadEnable,
ChannelTagReporterInThreadDisable,
ChannelReminder,
ChannelAutoAnswer,
ChannelTagReporterInThread,
ChannelLabelsStatistic,
ChannelLabelsList,
ChannelLabelsMerge,
Expand All @@ -50,7 +47,7 @@ def self.generate_help_text
ActionShowAction,
ThreadLabelsClean,
ThreadLabels,
UserCommits,
UserCommits
]

commands.map do |command|
Expand Down
9 changes: 3 additions & 6 deletions bot/commands/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
require_relative 'answer_enable_hide_reason'
require_relative 'answer_set_custom_text'
require_relative 'call_duty_person'
require_relative 'channel_reminder_disabled'
require_relative 'channel_reminder_enabled'
require_relative 'checked'
require_relative 'create_duty_for_user'
require_relative 'duty_create'
Expand All @@ -25,13 +23,12 @@
require_relative 'channel_labels_statistic'
require_relative 'channel_labels_list'
require_relative 'channel_labels_merge'
require_relative 'channel_reminder'
require_relative 'channel_tag_reporter_in_thread'
require_relative 'channel_auto_answer'
require_relative 'thread_labels_clean'
require_relative 'thread_labels'
require_relative 'git_commits'
require_relative 'channel_tag_reporter_in_thread_enable'
require_relative 'channel_tag_reporter_in_thread_disable'
require_relative 'channel_auto_answer_enable'
require_relative 'channel_auto_answer_disable'

module WhoIsOnDutyTodaySlackBotModule
module Commands
Expand Down
Loading
Loading