ruboty-ragoon 0.4.0 → 0.5.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 +25 -1
- data/lib/ruboty/actions/ragoon/remind.rb +13 -0
- data/lib/ruboty/handlers/ragoon.rb +5 -0
- data/lib/ruboty/ragoon/event.rb +10 -2
- data/lib/ruboty/ragoon/notification.rb +2 -7
- data/lib/ruboty/ragoon/notify_once.rb +16 -0
- data/lib/ruboty/ragoon/remind.rb +30 -0
- data/lib/ruboty/ragoon/version.rb +1 -1
- data/lib/ruboty/ragoon.rb +3 -0
- data/templates/remind.erb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 365fcaa8047997897a5982d851ba45aa1269d063
|
4
|
+
data.tar.gz: 3d5277c7becd73d215ede7d85f0b7fefe35c4e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec5ae459f34e10833b829582fdd8b3960f1746b1d5e44676ac166a5491b6b425a591e0a5de0794b1179a3c5ecbbdef736a6a61041b3fe3ab0c9d80db1c1da4c
|
7
|
+
data.tar.gz: 52b8c29e780656c57567f3a75aa67666f319207aa7dfd2dcf8d41099f4be33429eebe3fabf7aee54343aefa9d0abf5978c5a8408b08eebdd984ee641535c834e
|
data/README.md
CHANGED
@@ -22,7 +22,31 @@ Set these variables to connect your Garoon (required by Ragoon)
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
### Event
|
26
|
+
|
27
|
+
- `grn event[ date]`
|
28
|
+
- fetch events specified by `date`
|
29
|
+
- `date` allows `yesterday`, `today`, `tomorrow` and string that can bs parsed by `Date.parse`
|
30
|
+
- default : `today`
|
31
|
+
- private event
|
32
|
+
- mask place and description when replies in channel
|
33
|
+
- show place and detail when replies in direct message
|
34
|
+
|
35
|
+
### Notification
|
36
|
+
|
37
|
+
- `grn notice`
|
38
|
+
- show today's unread notifications
|
39
|
+
- replies only first time
|
40
|
+
- reminds notified ids in `Ruboty::Brains`
|
41
|
+
- better to use with `ruboty-cron`
|
42
|
+
- e.g) `ruboty add job "*/10 8-22 * * *" grn notice`
|
43
|
+
|
44
|
+
### Remind
|
45
|
+
|
46
|
+
- `grn remind`
|
47
|
+
- remind event before 3 minutes at start
|
48
|
+
- better to use with `ruboty-cron`
|
49
|
+
- e.g) `ruboty add job "* 8-22 * * *" grn remind`
|
26
50
|
|
27
51
|
## License
|
28
52
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty::Actions::Ragoon
|
2
|
+
class Remind < ::Ruboty::Actions::Base
|
3
|
+
include ::Ruboty::Actions::Ragoon
|
4
|
+
|
5
|
+
def call
|
6
|
+
reminder = ::Ruboty::Ragoon::Remind.new(message.robot.brain)
|
7
|
+
events = reminder.retrieve
|
8
|
+
if events.count > 0
|
9
|
+
message.reply(events.render(private: private?, template: 'remind'))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -3,6 +3,7 @@ module Ruboty
|
|
3
3
|
class Ragoon < Base
|
4
4
|
on(/grn event(?<date>\Z|\s+.+)/, name: 'schedule', description: 'retrieve schedule from garoon')
|
5
5
|
on(/grn notice/, name: 'notification', description: 'show new notification from garoon')
|
6
|
+
on(/grn remind/, name: 'remind', description: 'remind event before few minutes')
|
6
7
|
|
7
8
|
def schedule(message)
|
8
9
|
::Ruboty::Actions::Ragoon::Event.new(message).call
|
@@ -11,6 +12,10 @@ module Ruboty
|
|
11
12
|
def notification(message)
|
12
13
|
::Ruboty::Actions::Ragoon::Notification.new(message).call
|
13
14
|
end
|
15
|
+
|
16
|
+
def remind(message)
|
17
|
+
::Ruboty::Actions::Ragoon::Remind.new(message).call
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
data/lib/ruboty/ragoon/event.rb
CHANGED
@@ -15,8 +15,16 @@ module Ruboty
|
|
15
15
|
@events ||= ::Ragoon::Services::Schedule.new.schedule_get_events(::Ragoon::Services.start_and_end(date))
|
16
16
|
end
|
17
17
|
|
18
|
-
def render(private: false)
|
19
|
-
render_template(
|
18
|
+
def render(private: false, template: 'events')
|
19
|
+
render_template(template, events: format(private), date: self.date)
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter_events(&proc)
|
23
|
+
@events = @events.find_all { |event| proc.call(event) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def count
|
27
|
+
@events.count
|
20
28
|
end
|
21
29
|
|
22
30
|
private
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Ragoon
|
3
3
|
class Notification
|
4
|
+
include NotifyOnce
|
5
|
+
|
4
6
|
attr_reader :list, :brain
|
5
7
|
|
6
8
|
def initialize(brain)
|
@@ -26,13 +28,6 @@ module Ruboty
|
|
26
28
|
unread_count == 0
|
27
29
|
end
|
28
30
|
|
29
|
-
def not_notified_ids(new_notification_ids)
|
30
|
-
notified_ids = @brain.data['notification_notified_ids'] || []
|
31
|
-
notified_ids &= new_notification_ids
|
32
|
-
@brain.data['notification_notified_ids'] = notified_ids + new_notification_ids
|
33
|
-
new_notification_ids - notified_ids
|
34
|
-
end
|
35
|
-
|
36
31
|
class Item
|
37
32
|
attr_accessor :id, :module_type, :module_icon, :unread, :recieved_at, :subject, :url
|
38
33
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Ragoon
|
3
|
+
module NotifyOnce
|
4
|
+
def not_notified_ids(new_item_ids)
|
5
|
+
notified_item_ids = self.brain.data[brain_key] || []
|
6
|
+
notified_item_ids &= new_item_ids
|
7
|
+
self.brain.data[brain_key] = notified_item_ids + new_item_ids
|
8
|
+
new_item_ids - notified_item_ids
|
9
|
+
end
|
10
|
+
|
11
|
+
def brain_key
|
12
|
+
"#{self.class.name.downcase.gsub('::', '_')}_notified_ids"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Ragoon
|
3
|
+
class Remind
|
4
|
+
include NotifyOnce
|
5
|
+
attr_reader :brain, :event
|
6
|
+
|
7
|
+
NOTIFY_BEFORE_EVENT_START = 3 # minutes before start_at
|
8
|
+
|
9
|
+
def initialize(brain)
|
10
|
+
@brain = brain
|
11
|
+
end
|
12
|
+
|
13
|
+
def retrieve
|
14
|
+
now = Time.now.localtime
|
15
|
+
|
16
|
+
@event = Event.new
|
17
|
+
@event.filter_events do |event|
|
18
|
+
Time.parse(event[:start_at]).localtime - NOTIFY_BEFORE_EVENT_START * 60 < now
|
19
|
+
end
|
20
|
+
|
21
|
+
new_event_ids = not_notified_ids(@event.events.map { |event| event[:id] })
|
22
|
+
@event.filter_events do |event|
|
23
|
+
new_event_ids.include?(event[:id])
|
24
|
+
end
|
25
|
+
|
26
|
+
@event
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/ruboty/ragoon.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'ragoon'
|
2
2
|
require 'ruboty'
|
3
3
|
require 'ruboty/ragoon/config'
|
4
|
+
require 'ruboty/ragoon/notify_once'
|
4
5
|
require 'ruboty/ragoon/template'
|
5
6
|
require 'ruboty/ragoon/event'
|
6
7
|
require 'ruboty/ragoon/notification'
|
8
|
+
require 'ruboty/ragoon/remind'
|
7
9
|
require 'ruboty/ragoon/version'
|
8
10
|
require 'ruboty/actions/ragoon'
|
9
11
|
require 'ruboty/actions/ragoon/event'
|
10
12
|
require 'ruboty/actions/ragoon/notification'
|
13
|
+
require 'ruboty/actions/ragoon/remind'
|
11
14
|
require 'ruboty/handlers/ragoon'
|
12
15
|
require 'tilt'
|
13
16
|
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.5.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: 2016-01-
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -139,15 +139,19 @@ files:
|
|
139
139
|
- lib/ruboty/actions/ragoon.rb
|
140
140
|
- lib/ruboty/actions/ragoon/event.rb
|
141
141
|
- lib/ruboty/actions/ragoon/notification.rb
|
142
|
+
- lib/ruboty/actions/ragoon/remind.rb
|
142
143
|
- lib/ruboty/handlers/ragoon.rb
|
143
144
|
- lib/ruboty/ragoon.rb
|
144
145
|
- lib/ruboty/ragoon/config.rb
|
145
146
|
- lib/ruboty/ragoon/event.rb
|
146
147
|
- lib/ruboty/ragoon/notification.rb
|
148
|
+
- lib/ruboty/ragoon/notify_once.rb
|
149
|
+
- lib/ruboty/ragoon/remind.rb
|
147
150
|
- lib/ruboty/ragoon/template.rb
|
148
151
|
- lib/ruboty/ragoon/version.rb
|
149
152
|
- ruboty-ragoon.gemspec
|
150
153
|
- templates/events.erb
|
154
|
+
- templates/remind.erb
|
151
155
|
homepage: http://github.com/kwappa/ruboty-ragoon
|
152
156
|
licenses:
|
153
157
|
- MIT
|