ruboty-reminder 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruboty/handlers/reminder.rb +10 -12
- data/lib/ruboty/reminder/task.rb +2 -3
- data/lib/ruboty/reminder/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93fb18c3e643c38f4af4441b0823494061952f11
|
4
|
+
data.tar.gz: 82c4b5602bf80e1290b84e4ecad0bf1230737d20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db32f2201a7b285a3d5e2d8c0a968a8809ad3d601a92a38ea2e4c6974f20263cf896b954370e28cbe509071bac6278360a19c8b8e9992f77fae18e6045108e60
|
7
|
+
data.tar.gz: c45044e3319bd2d338ed800f82c2eb8af40d2861f549864cbeeb1d8e381e430859516267b9c0daba497b82ac15adfd3575061d1d793f0ffb81fabbfea35256d6
|
@@ -55,13 +55,11 @@ module Ruboty
|
|
55
55
|
task.start(robot)
|
56
56
|
message.reply("Reminder #{task.hash[:id]} is created.")
|
57
57
|
|
58
|
-
reminders[task.hash[:id]] = task
|
58
|
+
reminders[task.hash[:id]] = task.hash
|
59
59
|
end
|
60
60
|
|
61
61
|
def delete(message)
|
62
|
-
if
|
63
|
-
task.thread.kill
|
64
|
-
reminders.delete(message[:id].to_i)
|
62
|
+
if reminders.delete(message[:id].to_i)
|
65
63
|
message.reply("Reminder #{message[:id]} is deleted.")
|
66
64
|
else
|
67
65
|
message.reply("Reminder #{message[:id]} is not found.")
|
@@ -72,21 +70,21 @@ module Ruboty
|
|
72
70
|
if reminders.empty?
|
73
71
|
message.reply("The reminder doesn't exist.")
|
74
72
|
else
|
75
|
-
sorted_reminders = reminders.sort_by {|_id,
|
73
|
+
sorted_reminders = reminders.sort_by {|_id, hash| hash[:unixtime]}
|
76
74
|
|
77
|
-
reminder_list = sorted_reminders.map do |id,
|
78
|
-
date = "#{
|
79
|
-
time = "#{'%02d' %
|
80
|
-
"#{id}: #{date} #{time} -> #{
|
75
|
+
reminder_list = sorted_reminders.map do |id, hash|
|
76
|
+
date = "#{hash[:year]}/#{'%02d' % hash[:month]}/#{'%02d' % hash[:day]}"
|
77
|
+
time = "#{'%02d' % hash[:hour]}:#{'%02d' % hash[:min]}"
|
78
|
+
"#{id}: #{date} #{time} -> #{hash[:body]}"
|
81
79
|
end
|
82
80
|
message.reply(reminder_list.join("\n"), code: true)
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
86
84
|
def restart
|
87
|
-
reminders.each do |id,
|
88
|
-
|
89
|
-
|
85
|
+
reminders.each do |id, hash|
|
86
|
+
task = Ruboty::Reminder::Task.new(hash)
|
87
|
+
task.start(robot)
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
data/lib/ruboty/reminder/task.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Reminder
|
3
3
|
class Task
|
4
|
-
attr_reader :hash
|
4
|
+
attr_reader :hash
|
5
5
|
|
6
6
|
def initialize(hash)
|
7
7
|
@hash = hash
|
8
|
-
@thread = nil
|
9
8
|
end
|
10
9
|
|
11
10
|
def start(robot)
|
12
11
|
wait_time = hash[:unixtime] - Time.now.to_i
|
13
12
|
|
14
|
-
|
13
|
+
Thread.start do
|
15
14
|
sleep(wait_time)
|
16
15
|
Message.new(
|
17
16
|
hash.except(:id, :body, :year, :month, :day, :hour, :min, :unixtime).merge(robot: robot)
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaihar4
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.4.5
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Ruboty handler to remind a task.
|