lita-cron 0.0.1 → 0.0.2
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/lita/handlers/cron.rb +25 -15
- data/lita-cron.gemspec +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: 8395eac4f710aba0dbc952fee5d6e04274121faa
|
4
|
+
data.tar.gz: 1a52e06072341a815858bd3b8ee012a039e6a88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78d215ed82f4190e3a58a2207a286f5478bbe98b96145799aa19848ddf4ed270911588d84e86a50b109471913d43eb9599e81403a823ea7178efce39e07fce5c
|
7
|
+
data.tar.gz: 852e8f4414bb3dc9b3ee48ed1b45c5564f20f146228b6505d8e280458039aa5f62db35fb26ce65742d9391f1473bdbd36fb9832dadd01a36fbf514f06481aa95
|
data/lib/lita/handlers/cron.rb
CHANGED
@@ -18,6 +18,7 @@ module Lita
|
|
18
18
|
|
19
19
|
def initialize(robot)
|
20
20
|
super
|
21
|
+
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.default_config(config)
|
@@ -37,29 +38,26 @@ module Lita
|
|
37
38
|
"cron list" => "List all cron jobs."
|
38
39
|
})
|
39
40
|
|
40
|
-
|
41
41
|
def load_on_start(payload)
|
42
|
-
log.info "Initializing existing cron jobs."
|
43
42
|
jobs = redis.hgetall(REDIS_KEY)
|
44
43
|
jobs.each do |k,v|
|
45
44
|
j = JSON.parse(v)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
begin
|
46
|
+
job = Lita::Handlers.get_scheduler.cron j['cron_line'] do |job|
|
47
|
+
target = Source.new(user: j['u_id'], room: j['room'])
|
48
|
+
robot.send_messages(target, k)
|
49
|
+
log.info "MSG: #{k} -> #{target}"
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
response.reply
|
52
|
+
log.info "Created cron job: #{j['cron_line']} #{k}."
|
53
|
+
rescue ArgumentError => e
|
54
|
+
response.reply "argument error, perhaps the cronline? #{e.message}"
|
55
|
+
end
|
54
56
|
end
|
55
|
-
|
56
|
-
redis.hset(REDIS_KEY, message, { :cron_line => job.cron_line.original, :j_id => job.job_id }.to_json)
|
57
|
-
jobs = Lita::Handlers.get_scheduler.cron_jobs
|
58
|
-
return "New cron job: #{cron} #{message}"
|
59
57
|
end
|
60
58
|
|
61
59
|
def new(response)
|
62
|
-
|
60
|
+
log.info "NEW: #{response.matches} from #{response.message.source.user.id} in #{response.message.source.room}"
|
63
61
|
input = response.matches[0][0].split(" ")
|
64
62
|
cron = input[0..4].join(" ")
|
65
63
|
message = input[5..input.count()-1].join(" ")
|
@@ -68,7 +66,19 @@ module Lita
|
|
68
66
|
response.reply "#{message} already exists, delete first."
|
69
67
|
else
|
70
68
|
begin
|
71
|
-
|
69
|
+
job = Lita::Handlers.get_scheduler.cron cron do |job|
|
70
|
+
response.reply(message)
|
71
|
+
end
|
72
|
+
|
73
|
+
redis.hset(REDIS_KEY, message, {
|
74
|
+
:cron_line => job.cron_line.original,
|
75
|
+
:j_id => job.job_id,
|
76
|
+
:u_id => response.message.source.user.id,
|
77
|
+
:room => response.message.source.room }.to_json
|
78
|
+
)
|
79
|
+
jobs = Lita::Handlers.get_scheduler.cron_jobs
|
80
|
+
|
81
|
+
response.reply("New cron job: #{cron} #{message}")
|
72
82
|
rescue ArgumentError => e
|
73
83
|
response.reply "argument error, perhaps the cronline? #{e.message}"
|
74
84
|
end
|
data/lita-cron.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-cron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kit Plummer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|