ruboty-ragoon 0.2.1 → 0.3.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/lib/ruboty/actions/{ragoon.rb → event.rb} +6 -8
- data/lib/ruboty/actions/helpers.rb +13 -0
- data/lib/ruboty/actions/notification.rb +26 -0
- data/lib/ruboty/handlers/ragoon.rb +7 -2
- data/lib/ruboty/ragoon/notification.rb +58 -0
- data/lib/ruboty/ragoon/version.rb +1 -1
- data/lib/ruboty/ragoon.rb +4 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1547d9b16f5ca415568479da42434432fcba46c5
|
4
|
+
data.tar.gz: 0c9d49929f70a2e4abb588885851e62a92f1e06f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 018a478abe9bb10530a8a565943d8ee80cbfe034fc88ef339a1973a26ae59e1d7f53b216a6bdb85c9bdd546af2899016deb89a3f1d0ecd46908a48c6dfee43c5
|
7
|
+
data.tar.gz: 2d29aceceb69142fa2b4f3b14d6d26b5aa28034374fdf4f367ef080ef439b3181dca09de2999c2fe3b7dcaa149e46873a0a1c4bc9cbfa02ffd2fb0867e989e21
|
@@ -1,21 +1,19 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Actions
|
3
|
-
class
|
3
|
+
class Event < ::Ruboty::Actions::Base
|
4
|
+
include ::Ruboty::Actions::Helpers
|
5
|
+
|
4
6
|
def call
|
5
7
|
target_date = parse_date(message[:date])
|
6
8
|
events = ::Ruboty::Ragoon::Event.new(target_date)
|
7
|
-
message.reply(events.render(private:
|
9
|
+
message.reply(events.render(private: private?))
|
8
10
|
end
|
9
11
|
|
10
12
|
private
|
11
13
|
|
12
|
-
def check_private(message)
|
13
|
-
owner = message.original[:robot].send(:adapter).send(:user_info, ENV['SLACK_OWNER_ID'])
|
14
|
-
message.from.start_with?('D') && owner['name'] == message.from_name
|
15
|
-
end
|
16
|
-
|
17
14
|
def parse_date(date)
|
18
|
-
|
15
|
+
date = date.strip.downcase
|
16
|
+
case date
|
19
17
|
when 'today'
|
20
18
|
Date.today
|
21
19
|
when 'tomorrow'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Actions
|
3
|
+
module Helpers
|
4
|
+
def private?
|
5
|
+
adapter = message.original[:robot].send(:adapter)
|
6
|
+
return false unless adapter.respond_to?(:user_info)
|
7
|
+
|
8
|
+
owner = adapter.send(:user_info, ENV['SLACK_OWNER_ID'])
|
9
|
+
message.from.start_with?('D') && owner['name'] == message.from_name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Actions
|
3
|
+
class Notification < ::Ruboty::Actions::Base
|
4
|
+
include ::Ruboty::Actions::Helpers
|
5
|
+
|
6
|
+
def call
|
7
|
+
notifications = ::Ruboty::Ragoon::Notification.new
|
8
|
+
unless notifications.empty?
|
9
|
+
reply = [":new: #{notifications.unread_count}件の新着通知があります #{notification_url}"]
|
10
|
+
|
11
|
+
if private?
|
12
|
+
reply += notifications.list.find_all(&:unread).map(&:format)
|
13
|
+
end
|
14
|
+
|
15
|
+
message.reply(reply.join("\n"))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def notification_url
|
22
|
+
"#{::Ragoon::garoon_endpoint.gsub(/\?.*\Z/, '')}/notification/index"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Handlers
|
3
3
|
class Ragoon < Base
|
4
|
-
on(/
|
4
|
+
on(/grn event(?<date>\Z|\s+.+)/, name: 'schedule', description: 'retrieve schedule from garoon')
|
5
|
+
on(/grn notice/, name: 'notification', description: 'show new notification from garoon')
|
5
6
|
|
6
7
|
def schedule(message)
|
7
|
-
::Ruboty::Actions::
|
8
|
+
::Ruboty::Actions::Event.new(message).call
|
9
|
+
end
|
10
|
+
|
11
|
+
def notification(message)
|
12
|
+
::Ruboty::Actions::Notification.new(message).call
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Ragoon
|
3
|
+
class Notification
|
4
|
+
attr_reader :list
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
retrieve
|
8
|
+
end
|
9
|
+
|
10
|
+
def retrieve
|
11
|
+
@list = ::Ragoon::Services::Notification.new.retrieve.map { |data| Item.new(data) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def unread_count
|
15
|
+
@list.count { |item| item.unread }
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty?
|
19
|
+
unread_count == 0
|
20
|
+
end
|
21
|
+
|
22
|
+
class Item
|
23
|
+
attr_accessor :id, :module_type, :module_icon, :unread, :recieved_at, :subject, :url
|
24
|
+
|
25
|
+
DEFAULT_ICON = ':information_source:'
|
26
|
+
|
27
|
+
APPLICATION_ICONS = {
|
28
|
+
'grn.schedule' => ':memo:', # スケジュール
|
29
|
+
'grn.schedule.facility_approval' => DEFAULT_ICON, # 施設の利用申請
|
30
|
+
'grn.message' => ':incoming_envelope:', # メッセージ
|
31
|
+
'grn.bulletin' => ':clipboard:', # 掲示板
|
32
|
+
'grn.cabinet' => ':open_file_folder:', # ファイル管理
|
33
|
+
'grn.phonemessage' => ':phone:', # 電話メモ
|
34
|
+
'grn.mail' => ':mailbox_with_mail:', # メール
|
35
|
+
'grn.workflow' => ':inbox_tray:', # ワークフロー
|
36
|
+
'grn.report' => DEFAULT_ICON, # マルチレポート
|
37
|
+
'grn.space' => DEFAULT_ICON, # スペース
|
38
|
+
'grn.space.discussion' => DEFAULT_ICON, # スペースのディスカッション
|
39
|
+
'grn.space.todo' => DEFAULT_ICON, # スペースの共有ToDo
|
40
|
+
}.freeze
|
41
|
+
|
42
|
+
def initialize(data)
|
43
|
+
@id = data[:item].to_i
|
44
|
+
@module_type = data[:module_id].gsub('grn.', '').gsub('.', '_').to_sym
|
45
|
+
@module_icon = APPLICATION_ICONS[data[:module_id]]
|
46
|
+
@unread = data[:is_history] == 'false'
|
47
|
+
@recieved_at = Time.parse(data[:receive_datetime])
|
48
|
+
@subject = data[:subject]
|
49
|
+
@url = data[:abstract_url]
|
50
|
+
end
|
51
|
+
|
52
|
+
def format
|
53
|
+
"#{@module_icon} #{@subject[0 .. 30]} #{@url}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/ruboty/ragoon.rb
CHANGED
@@ -3,8 +3,11 @@ require 'ruboty'
|
|
3
3
|
require 'ruboty/ragoon/config'
|
4
4
|
require 'ruboty/ragoon/template'
|
5
5
|
require 'ruboty/ragoon/event'
|
6
|
+
require 'ruboty/ragoon/notification'
|
6
7
|
require 'ruboty/ragoon/version'
|
7
|
-
require 'ruboty/actions/
|
8
|
+
require 'ruboty/actions/helpers'
|
9
|
+
require 'ruboty/actions/event'
|
10
|
+
require 'ruboty/actions/notification'
|
8
11
|
require 'ruboty/handlers/ragoon'
|
9
12
|
require 'tilt'
|
10
13
|
require 'tilt/erb'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-ragoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SHIOYA, Hiromu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -92,11 +92,14 @@ files:
|
|
92
92
|
- LICENSE.txt
|
93
93
|
- README.md
|
94
94
|
- Rakefile
|
95
|
-
- lib/ruboty/actions/
|
95
|
+
- lib/ruboty/actions/event.rb
|
96
|
+
- lib/ruboty/actions/helpers.rb
|
97
|
+
- lib/ruboty/actions/notification.rb
|
96
98
|
- lib/ruboty/handlers/ragoon.rb
|
97
99
|
- lib/ruboty/ragoon.rb
|
98
100
|
- lib/ruboty/ragoon/config.rb
|
99
101
|
- lib/ruboty/ragoon/event.rb
|
102
|
+
- lib/ruboty/ragoon/notification.rb
|
100
103
|
- lib/ruboty/ragoon/template.rb
|
101
104
|
- lib/ruboty/ragoon/version.rb
|
102
105
|
- ruboty-ragoon.gemspec
|
@@ -121,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
124
|
version: '0'
|
122
125
|
requirements: []
|
123
126
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.1
|
125
128
|
signing_key:
|
126
129
|
specification_version: 4
|
127
130
|
summary: ruboty handlers to use ragoon
|