ruboty-slack_take_turns 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/ruboty/handlers/slack_take_turns.rb +2 -2
- data/lib/ruboty/slack_take_turns.rb +0 -0
- data/lib/ruboty/slack_take_turns/actions/assign.rb +0 -0
- data/lib/ruboty/slack_take_turns/actions/base.rb +0 -0
- data/lib/ruboty/slack_take_turns/actions/current.rb +0 -0
- data/lib/ruboty/slack_take_turns/actions/exclude.rb +10 -5
- data/lib/ruboty/slack_take_turns/actions/force.rb +0 -0
- data/lib/ruboty/slack_take_turns/actions/include.rb +10 -5
- data/lib/ruboty/slack_take_turns/actions/members.rb +0 -0
- data/lib/ruboty/slack_take_turns/actions/next.rb +0 -0
- data/lib/ruboty/slack_take_turns/locale/en.yml +4 -2
- data/lib/ruboty/slack_take_turns/locale/ja.yml +4 -2
- data/lib/ruboty/slack_take_turns/slack_client.rb +16 -15
- data/lib/ruboty/slack_take_turns/version.rb +1 -1
- data/ruboty-slack_take_turns.gemspec +0 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 28faeedaaa8d7e387c3640429ea093de59165aeb2661205d4aa0fbd98a663d72
|
4
|
+
data.tar.gz: f0ad79e131d11bf74ffab2fa4c4496e1e9193e11180f6e9ac75d02c263485555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f5c290764fdcffc94a00a52000280a25ce1446212d950ca3df0eb9df2c32442e1faa931fefbe56c80f63f12ce35d2449b72656fa815df8c70938563d1cdac7b
|
7
|
+
data.tar.gz: 291f67b30121a52378df4f1b190e1e173dfd8565ab991d7c17f01fa3ec39f41291a8c8b8f237d4098ec7b5d18365b3eeb9e3d2c62457c96bfc975befec763b09
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
@@ -25,12 +25,12 @@ module Ruboty
|
|
25
25
|
description: "#{I18n.t 'messages.handlers.next'}",
|
26
26
|
)
|
27
27
|
on(
|
28
|
-
/exclude (?<
|
28
|
+
/exclude (?<space_separated_user_names>.+?)\z/,
|
29
29
|
name: "exclude",
|
30
30
|
description: "#{I18n.t 'messages.handlers.exclude'}",
|
31
31
|
)
|
32
32
|
on(
|
33
|
-
/include (?<
|
33
|
+
/include (?<space_separated_user_names>.+?)\z/,
|
34
34
|
name: "include",
|
35
35
|
description: "#{I18n.t 'messages.handlers.include'}",
|
36
36
|
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -15,12 +15,17 @@ module Ruboty
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def exclude
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
user_names = message[:space_separated_user_names].strip.delete('@').split(/\s*,\s*/)
|
19
|
+
excluded_user_names = []
|
20
|
+
user_names.each do |user_name|
|
21
|
+
user_id = find_user_id_by_user_name(user_name)
|
22
|
+
unless excluded_user_ids.include? user_id
|
23
|
+
excluded_user_ids << user_id
|
24
|
+
excluded_user_names << user_name
|
25
|
+
end
|
22
26
|
end
|
23
|
-
|
27
|
+
return I18n.t 'messages.actions.exclude_failure' if excluded_user_names.empty?
|
28
|
+
"#{I18n.t 'messages.actions.exclude', user_name: excluded_user_names.map{|name| "@#{name}"}.join(', ')}"
|
24
29
|
end
|
25
30
|
|
26
31
|
end
|
File without changes
|
@@ -15,12 +15,17 @@ module Ruboty
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def include
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
user_names = message[:space_separated_user_names].strip.delete('@').split(/\s*,\s*/)
|
19
|
+
included_user_names = []
|
20
|
+
user_names.each do |user_name|
|
21
|
+
user_id = find_user_id_by_user_name(user_name)
|
22
|
+
if excluded_user_ids.include? user_id
|
23
|
+
excluded_user_ids.delete user_id
|
24
|
+
included_user_names << user_name
|
25
|
+
end
|
22
26
|
end
|
23
|
-
|
27
|
+
return I18n.t 'messages.actions.include_failure' if included_user_names.empty?
|
28
|
+
"#{I18n.t 'messages.actions.include', user_name: included_user_names.map{|name| "@#{name}"}.join(', ')}"
|
24
29
|
end
|
25
30
|
|
26
31
|
end
|
File without changes
|
File without changes
|
@@ -13,8 +13,10 @@ en:
|
|
13
13
|
@%{current_user_name}, please deal with the task below.
|
14
14
|
%{keyword}
|
15
15
|
current: "@%{current_user_name} is on duty now."
|
16
|
-
exclude: made
|
17
|
-
|
16
|
+
exclude: made %{user_name} to not be on duty after this.
|
17
|
+
exclude_failure: Exclude failure. spelling mistake?.
|
18
|
+
include: made %{user_name} to be on duty after this.
|
19
|
+
include_failure: Include failure. spelling mistake?.
|
18
20
|
force:
|
19
21
|
ok: made @%{user_name} to take over a duty
|
20
22
|
ng: "%{user_name} is free from a duty"
|
@@ -13,8 +13,10 @@ ja:
|
|
13
13
|
@%{current_user_name}さん、下記の対応をお願いします。
|
14
14
|
%{keyword}
|
15
15
|
current: "現在の当番は@%{current_user_name}さんです"
|
16
|
-
exclude: "
|
17
|
-
|
16
|
+
exclude: "%{user_name}さんを当番から除外しました"
|
17
|
+
exclude_failure: "当番から除外するのに失敗しました。スペルミス?"
|
18
|
+
include: "%{user_name}さんを当番に加えました"
|
19
|
+
include_failure: "当番に追加するのに失敗しました。スペルミス?"
|
18
20
|
force:
|
19
21
|
ok: "@%{user_name}さんを当番にしました"
|
20
22
|
ng: "%{user_name}さんは当番から除外されています"
|
@@ -7,6 +7,7 @@ module Ruboty
|
|
7
7
|
def initialize(channel)
|
8
8
|
@client ||= Slack::Client.new(token: ENV['SLACK_TOKEN'])
|
9
9
|
@channel = channel
|
10
|
+
@channels_info = {}
|
10
11
|
end
|
11
12
|
|
12
13
|
def all_users
|
@@ -24,32 +25,32 @@ module Ruboty
|
|
24
25
|
def channel_user_ids
|
25
26
|
unless @channel_user_ids&.dig(channel)
|
26
27
|
@channel_user_ids = {} unless @channel_user_ids
|
27
|
-
ids = private_channel? ? private_channel_user_ids : public_channel_user_ids
|
28
|
+
ids = private_channel?(channel) ? private_channel_user_ids(channel) : public_channel_user_ids(channel)
|
29
|
+
# 退職してアカウント停止した人とボットは除く
|
30
|
+
ids = ids.select{|id| user = find_user_by_user_id(id); !user['deleted'] && !user['is_bot']}
|
28
31
|
@channel_user_ids[channel] = ids.sort
|
29
32
|
end
|
30
33
|
@channel_user_ids[channel]
|
31
34
|
end
|
32
35
|
|
33
|
-
def
|
34
|
-
|
36
|
+
def public_channel_user_ids(channel)
|
37
|
+
channel_info = @channels_info[channel]
|
38
|
+
@channels_info[channel] = client.channels_info(channel: channel) unless channel_info
|
39
|
+
@channels_info[channel]['channel']['members']
|
35
40
|
end
|
36
41
|
|
37
|
-
def
|
38
|
-
channels_info[
|
42
|
+
def private_channel_user_ids(channel)
|
43
|
+
channel_info = @channels_info[channel]
|
44
|
+
@channels_info[channel] = client.groups_info(channel: channel) unless channel_info
|
45
|
+
@channels_info[channel]['group']['members']
|
39
46
|
end
|
40
47
|
|
41
|
-
def
|
42
|
-
|
43
|
-
current_channel = private_channels.find{|c| c['id'] == channel}
|
44
|
-
current_channel['members']
|
48
|
+
def private_channel?(channel)
|
49
|
+
channel[0] == "G"
|
45
50
|
end
|
46
51
|
|
47
|
-
def
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
def private_channel?
|
52
|
-
channels_info['error'] == "channel_not_found"
|
52
|
+
def find_user_by_user_id(user_id)
|
53
|
+
all_users_hash[user_id] || raise("user not found user_id: #{user_id}#")
|
53
54
|
end
|
54
55
|
|
55
56
|
end
|
File without changes
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oharato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -115,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
|
119
|
-
rubygems_version: 2.5.2
|
118
|
+
rubygems_version: 3.0.3
|
120
119
|
signing_key:
|
121
120
|
specification_version: 4
|
122
121
|
summary: Ruboty plugin to manage a duty that members in a slack channel take turns
|