ruboty-reminder 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/ruboty/handlers/reminder.rb +12 -14
- data/lib/ruboty/reminder/task.rb +12 -5
- data/lib/ruboty/reminder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c56465750cafb460b35d7e84402b23590ea03d6f
|
4
|
+
data.tar.gz: c3c163fe199748c4f45ae8caf74f941d3ba7abfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cc958e1a1ae1774962297d3d5303302f9467605165e8831bafa9e50a29606439ad7dc1e6f1b439bb179b6b1adf5fe640192f71872415e367d7cbd5fa750d6d3
|
7
|
+
data.tar.gz: 0a18aa9fb81d7186fb5647f7f07d28ef8641341539f839f8a52da0e982c77249e15cc3c81f041aaac56683ebf41434d0323f07be7f8e1f6b3c4bd9d5db81a3d9
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ module Ruboty
|
|
5
5
|
|
6
6
|
on /add task (?<hh>\d{2}):(?<mm>\d{2}) (?<task>.+)/, name: 'add', description: 'Add a task'
|
7
7
|
on /delete task (?<id>.+)/, name: 'delete', description: 'Delete a task'
|
8
|
-
on /list tasks/, name: 'list', description: 'Show all reminders'
|
8
|
+
on /list tasks\z/, name: 'list', description: 'Show all reminders'
|
9
9
|
|
10
10
|
def initialize(*args)
|
11
11
|
super
|
@@ -31,7 +31,7 @@ module Ruboty
|
|
31
31
|
)
|
32
32
|
)
|
33
33
|
task.start(robot)
|
34
|
-
message.reply("Task #{task.hash[:id]} created.")
|
34
|
+
message.reply("Task #{task.hash[:id]} is created.")
|
35
35
|
|
36
36
|
# Insert to the brain
|
37
37
|
tasks[task.hash[:id]] = task.hash
|
@@ -39,23 +39,21 @@ module Ruboty
|
|
39
39
|
|
40
40
|
def delete(message)
|
41
41
|
if tasks.delete(message[:id].to_i)
|
42
|
-
message.reply(
|
42
|
+
message.reply("Task #{message[:id]} is deleted.")
|
43
43
|
else
|
44
|
-
message.reply(
|
44
|
+
message.reply("Task #{message[:id]} is not found.")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def list(message)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
message.reply(body)
|
49
|
+
if tasks.empty?
|
50
|
+
message.reply("The task doesn't exist.")
|
51
|
+
else
|
52
|
+
task_list = tasks.map do |id, hash|
|
53
|
+
"#{id}: #{'%02d' % hash[:hour]}:#{'%02d' % hash[:min]} -> #{hash[:body]}"
|
54
|
+
end.join("\n")
|
55
|
+
message.reply(task_list, code: true)
|
56
|
+
end
|
59
57
|
end
|
60
58
|
|
61
59
|
def restart
|
data/lib/ruboty/reminder/task.rb
CHANGED
@@ -10,14 +10,21 @@ module Ruboty
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def start(robot)
|
13
|
-
current_time = Time.
|
14
|
-
|
13
|
+
current_time = Time.new.to_i
|
14
|
+
target_time = Time.new(
|
15
|
+
Time.now.year,
|
16
|
+
Time.now.month,
|
17
|
+
Time.now.day,
|
18
|
+
hash[:hour],
|
19
|
+
hash[:min],
|
20
|
+
0
|
21
|
+
).to_i
|
15
22
|
|
16
23
|
wait_time =
|
17
|
-
if
|
18
|
-
(
|
24
|
+
if target_time - current_time < 0
|
25
|
+
(target_time + 24*60*60) - current_time
|
19
26
|
else
|
20
|
-
|
27
|
+
target_time - current_time
|
21
28
|
end
|
22
29
|
|
23
30
|
Thread.start do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-reminder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaihar4
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|