ruboty-slack_take_turns 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +62 -2
- data/lib/ruboty/handlers/slack_take_turns.rb +15 -6
- data/lib/ruboty/slack_take_turns/actions/assign.rb +1 -4
- data/lib/ruboty/slack_take_turns/actions/base.rb +3 -3
- data/lib/ruboty/slack_take_turns/actions/current.rb +1 -1
- data/lib/ruboty/slack_take_turns/actions/exclude.rb +1 -1
- data/lib/ruboty/slack_take_turns/actions/force.rb +2 -2
- data/lib/ruboty/slack_take_turns/actions/include.rb +29 -0
- data/lib/ruboty/slack_take_turns/actions/next.rb +1 -1
- data/lib/ruboty/slack_take_turns/locale/en.yml +23 -0
- data/lib/ruboty/slack_take_turns/locale/ja.yml +24 -0
- data/lib/ruboty/slack_take_turns/version.rb +1 -1
- data/lib/ruboty/slack_take_turns.rb +10 -1
- data/ruboty-slack_take_turns.gemspec +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c02cb32a888758f34bd395c531d2302001e116f8
|
4
|
+
data.tar.gz: 975ef1517ccb6e3ce4326ed2dc83e5784a06c0ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45016c4328a08599f893afc974ecb34446177b252d7865718f8fdd95207e91a06849f2ba951b38dac16aabb7183816ca0747c4b185cc54f900c47509ecf717eb
|
7
|
+
data.tar.gz: '029b04eeb7b19020613d8fa0dab444e6fe91703887688dd473e83b361fdb5858d56327237f809535c197d243c47cc327b3c96444aaa4f8518d406fc32423bc38'
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Ruboty plugin to manage a duty that members in a slack channel take turns on
|
4
4
|
|
5
|
+
## Dependencies
|
6
|
+
- ruboty
|
7
|
+
- ruboty-slack_rtm
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -18,9 +22,65 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
$ gem install ruboty-slack_take_turns
|
20
24
|
|
25
|
+
## ENV
|
26
|
+
```
|
27
|
+
SLACK_TOKEN - Browse Apps > Custom Integrations > Bots > API Token
|
28
|
+
ASSIGN_REGEX - e.g. .*http:\/\/example.com\/issues.*
|
29
|
+
# Default language is English. If you add below, messages is displayed in Japanese.
|
30
|
+
SLACK_TAKE_TURNS_LANG=ja
|
31
|
+
```
|
32
|
+
|
33
|
+
## Commands
|
34
|
+
```
|
35
|
+
ruobty /current/ - show who is on duty currently
|
36
|
+
ruobty /exclude (?<user_name>.+?)\z/ - make a specified member to not be on duty after this
|
37
|
+
ruobty /include (?<user_name>.+?)\z/ - make a specified member to be on duty after this
|
38
|
+
ruobty /force (?<user_name>.+?)\z/ - make a specified member to be on duty
|
39
|
+
ruobty /members/ - member list in a channel(order by slack-user-id asc)
|
40
|
+
ruobty /next/ - pass on a duty to the next member
|
41
|
+
/(?<keyword>.*http:\/\/example.com\/issues.*)/m - When a macthed keyword is posted, the bot assigns a person on duty to a task related the keyword.
|
42
|
+
```
|
43
|
+
|
21
44
|
## Usage
|
22
45
|
|
23
|
-
|
46
|
+
### check members
|
47
|
+
```
|
48
|
+
> ruboty members
|
49
|
+
oharato, jimmy, ellen, ruboty
|
50
|
+
```
|
51
|
+
|
52
|
+
### set the first person on duty
|
53
|
+
```
|
54
|
+
> ruboty force oharato
|
55
|
+
made @oharato to take over a duty
|
56
|
+
```
|
57
|
+
|
58
|
+
check current status
|
59
|
+
```
|
60
|
+
> ruboty current
|
61
|
+
@oharato is on duty now.
|
62
|
+
```
|
63
|
+
|
64
|
+
```
|
65
|
+
> ruboty members
|
66
|
+
[flag]oharato, jimmy, ellen, ruboty
|
67
|
+
```
|
68
|
+
|
69
|
+
### post a keyword you set in .env
|
70
|
+
```
|
71
|
+
> http://example.com/issues/42
|
72
|
+
@oharato, please deal with the task below.
|
73
|
+
http://example.com/issues/42
|
74
|
+
```
|
75
|
+
|
76
|
+
### pass on a duty to the next member
|
77
|
+
```
|
78
|
+
> ruboty next
|
79
|
+
passed on a duty to the next member. @jimmy is on duty now.
|
80
|
+
```
|
81
|
+
|
82
|
+
## Notice
|
83
|
+
- You should use a ruboty brain plugin such as ruboty-local_yaml and ruboty-redis.
|
24
84
|
|
25
85
|
## Development
|
26
86
|
|
@@ -30,5 +90,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
90
|
|
31
91
|
## Contributing
|
32
92
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/oharato/ruboty-slack_take_turns.
|
34
94
|
|
@@ -7,32 +7,37 @@ module Ruboty
|
|
7
7
|
on(
|
8
8
|
/members/,
|
9
9
|
name: "members",
|
10
|
-
description: "
|
10
|
+
description: "#{I18n.t 'messages.handlers.members'}"
|
11
11
|
)
|
12
12
|
on(
|
13
13
|
/force (?<user_name>.+?)\z/,
|
14
14
|
name: "force",
|
15
|
-
description: "
|
15
|
+
description: "#{I18n.t 'messages.handlers.force'}",
|
16
16
|
)
|
17
17
|
on(
|
18
18
|
/current/,
|
19
19
|
name: "current",
|
20
|
-
description: "
|
20
|
+
description: "#{I18n.t 'messages.handlers.current'}",
|
21
21
|
)
|
22
22
|
on(
|
23
23
|
/next/,
|
24
24
|
name: "next",
|
25
|
-
description: "
|
25
|
+
description: "#{I18n.t 'messages.handlers.next'}",
|
26
26
|
)
|
27
27
|
on(
|
28
28
|
/exclude (?<user_name>.+?)\z/,
|
29
29
|
name: "exclude",
|
30
|
-
description: "
|
30
|
+
description: "#{I18n.t 'messages.handlers.exclude'}",
|
31
|
+
)
|
32
|
+
on(
|
33
|
+
/include (?<user_name>.+?)\z/,
|
34
|
+
name: "include",
|
35
|
+
description: "#{I18n.t 'messages.handlers.include'}",
|
31
36
|
)
|
32
37
|
on(
|
33
38
|
/(?<keyword>#{ENV['ASSIGN_REGEX']})/m,
|
34
39
|
name: "assign",
|
35
|
-
description: "
|
40
|
+
description: "#{I18n.t 'messages.handlers.assign'}",
|
36
41
|
all: true,
|
37
42
|
)
|
38
43
|
|
@@ -59,6 +64,10 @@ module Ruboty
|
|
59
64
|
Ruboty::SlackTakeTurns::Actions::Exclude.new(message).call
|
60
65
|
end
|
61
66
|
|
67
|
+
def include(message)
|
68
|
+
Ruboty::SlackTakeTurns::Actions::Include.new(message).call
|
69
|
+
end
|
70
|
+
|
62
71
|
def assign(message)
|
63
72
|
Ruboty::SlackTakeTurns::Actions::Assign.new(message).call
|
64
73
|
end
|
@@ -18,10 +18,7 @@ module Ruboty
|
|
18
18
|
# avoid self-repeating
|
19
19
|
return if message.from_name == message.robot.name
|
20
20
|
keyword = message[:keyword]
|
21
|
-
|
22
|
-
@#{current_user_name}, please deal with the task below.
|
23
|
-
#{keyword}
|
24
|
-
EOF
|
21
|
+
"#{I18n.t 'messages.actions.assign', current_user_name: current_user_name, keyword: keyword}"
|
25
22
|
end
|
26
23
|
|
27
24
|
end
|
@@ -2,7 +2,7 @@ module Ruboty
|
|
2
2
|
module SlackTakeTurns
|
3
3
|
module Actions
|
4
4
|
class Base
|
5
|
-
NAMESPACE = '
|
5
|
+
NAMESPACE = 'slack_take_turns'
|
6
6
|
|
7
7
|
attr_reader :message
|
8
8
|
|
@@ -79,13 +79,13 @@ module Ruboty
|
|
79
79
|
|
80
80
|
class CurrentUserNotFound < ActionBaseError
|
81
81
|
def message
|
82
|
-
"
|
82
|
+
"#{I18n.t 'errors.current_user_not_found'}"
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
class UserNotFound < ActionBaseError
|
87
87
|
def message
|
88
|
-
"#{
|
88
|
+
"#{I18n.t 'errors.user_not_found', user_name: @user_name}"
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -19,9 +19,9 @@ module Ruboty
|
|
19
19
|
user_id = find_user_id_by_user_name(user_name)
|
20
20
|
if target_user_ids.include? user_id
|
21
21
|
channel_data[:current_user_id] = user_id
|
22
|
-
"
|
22
|
+
"#{I18n.t 'messages.actions.force.ok', user_name: user_name}"
|
23
23
|
else
|
24
|
-
"#{
|
24
|
+
"#{I18n.t 'messages.actions.force.ng', user_name: user_name}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module SlackTakeTurns
|
3
|
+
module Actions
|
4
|
+
class Include < Base
|
5
|
+
def call
|
6
|
+
message.reply(include)
|
7
|
+
rescue ActionBaseError => e
|
8
|
+
message.reply(e.message)
|
9
|
+
Ruboty.logger.info e.to_s
|
10
|
+
rescue => e
|
11
|
+
message.reply(e.message)
|
12
|
+
raise e
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def include
|
18
|
+
user_name = message[:user_name]
|
19
|
+
user_id = find_user_id_by_user_name(user_name)
|
20
|
+
if excluded_user_ids.include? user_id
|
21
|
+
excluded_user_ids.delete user_id
|
22
|
+
end
|
23
|
+
"#{I18n.t 'messages.actions.include', user_name: user_name}"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
en:
|
2
|
+
messages:
|
3
|
+
handlers:
|
4
|
+
members: member list in a channel(order by slack-user-id asc)
|
5
|
+
force: make a specified member to be on duty
|
6
|
+
current: show who is on duty currently
|
7
|
+
next: pass on a duty to the next member
|
8
|
+
exclude: make a specified member to not be on duty after this
|
9
|
+
assign: When a macthed keyword is posted, the bot assigns a person on duty to a task related the keyword.
|
10
|
+
actions:
|
11
|
+
assign: |
|
12
|
+
@%{current_user_name}, please deal with the task below.
|
13
|
+
%{keyword}
|
14
|
+
current: "@%{current_user_name} is on duty now."
|
15
|
+
exclude: made @%{user_name} to not be on duty after this
|
16
|
+
include: made @%{user_name} to be on duty after this
|
17
|
+
force:
|
18
|
+
ok: made @%{user_name} to take over a duty
|
19
|
+
ng: "%{user_name} is free from a duty"
|
20
|
+
next: passed on a duty to the next member. @%{current_user_name} is on duty now.
|
21
|
+
errors:
|
22
|
+
current_user_not_found: not specified who is on duty. use 'force' command
|
23
|
+
user_not_found: "%{user_name} is not found. spelling mistake?"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
ja:
|
2
|
+
messages:
|
3
|
+
handlers:
|
4
|
+
members: 当番一覧 (slackユーザIDの昇順)
|
5
|
+
force: 当番を指定します
|
6
|
+
current: 現在の当番を表示します
|
7
|
+
next: 当番をまわします
|
8
|
+
exclude: メンバーを当番から除外します
|
9
|
+
include: メンバーを当番に加えます
|
10
|
+
assign: キーワードが投稿されると、現在の当番にキーワードに関する当番の依頼をします
|
11
|
+
actions:
|
12
|
+
assign: |
|
13
|
+
@%{current_user_name}さん、下記の対応をお願いします。
|
14
|
+
%{keyword}
|
15
|
+
current: "現在の当番は@%{current_user_name}さんです"
|
16
|
+
exclude: "@%{user_name}さんを当番から除外しました"
|
17
|
+
include: "@%{user_name}さんを当番に加えました"
|
18
|
+
force:
|
19
|
+
ok: "@%{user_name}さんを当番にしました"
|
20
|
+
ng: "%{user_name}さんは当番から除外されています"
|
21
|
+
next: 当番をまわしました。現在の当番は@%{current_user_name}さんです
|
22
|
+
errors:
|
23
|
+
current_user_not_found: 当番が指定されていません。'force'コマンドを使ってください
|
24
|
+
user_not_found: "%{user_name}さんが見つかりませんでした。スペルミス?"
|
@@ -1,15 +1,24 @@
|
|
1
|
+
require "i18n"
|
2
|
+
I18n.load_path = []
|
3
|
+
Dir.glob("#{File.expand_path('../slack_take_turns', __FILE__)}/locale/*.yml").each do |f|
|
4
|
+
lang = []
|
5
|
+
lang << f
|
6
|
+
I18n.load_path << lang
|
7
|
+
end
|
8
|
+
I18n.enforce_available_locales = false
|
9
|
+
I18n.default_locale = ENV['SLACK_TAKE_TURNS_LANG'] ? ENV['SLACK_TAKE_TURNS_LANG'].to_sym : :en
|
1
10
|
require "ruboty"
|
2
11
|
require "ruboty/slack_take_turns/slack_client"
|
3
12
|
require "ruboty/slack_take_turns/actions/base"
|
4
13
|
require "ruboty/slack_take_turns/actions/assign"
|
5
14
|
require "ruboty/slack_take_turns/actions/current"
|
6
15
|
require "ruboty/slack_take_turns/actions/exclude"
|
16
|
+
require "ruboty/slack_take_turns/actions/include"
|
7
17
|
require "ruboty/slack_take_turns/actions/force"
|
8
18
|
require "ruboty/slack_take_turns/actions/members"
|
9
19
|
require "ruboty/slack_take_turns/actions/next"
|
10
20
|
require "ruboty/slack_take_turns/version"
|
11
21
|
require "ruboty/handlers/slack_take_turns"
|
12
|
-
|
13
22
|
module Ruboty
|
14
23
|
module SlackTakeTurns
|
15
24
|
# Your code goes here...
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-slack_take_turns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oharato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i18n
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Ruboty plugin to manage a duty that members in a slack channel take turns
|
56
70
|
on
|
57
71
|
email:
|
@@ -74,8 +88,11 @@ files:
|
|
74
88
|
- lib/ruboty/slack_take_turns/actions/current.rb
|
75
89
|
- lib/ruboty/slack_take_turns/actions/exclude.rb
|
76
90
|
- lib/ruboty/slack_take_turns/actions/force.rb
|
91
|
+
- lib/ruboty/slack_take_turns/actions/include.rb
|
77
92
|
- lib/ruboty/slack_take_turns/actions/members.rb
|
78
93
|
- lib/ruboty/slack_take_turns/actions/next.rb
|
94
|
+
- lib/ruboty/slack_take_turns/locale/en.yml
|
95
|
+
- lib/ruboty/slack_take_turns/locale/ja.yml
|
79
96
|
- lib/ruboty/slack_take_turns/slack_client.rb
|
80
97
|
- lib/ruboty/slack_take_turns/version.rb
|
81
98
|
- ruboty-slack_take_turns.gemspec
|
@@ -99,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
116
|
version: '0'
|
100
117
|
requirements: []
|
101
118
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.5.
|
119
|
+
rubygems_version: 2.5.2
|
103
120
|
signing_key:
|
104
121
|
specification_version: 4
|
105
122
|
summary: Ruboty plugin to manage a duty that members in a slack channel take turns
|