-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.ru
33 lines (30 loc) · 1014 Bytes
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$:.unshift File.expand_path('../lib', __FILE__)
require 'json'
require 'chrono'
require 'ayaneru'
run Ayaneru::Server
Thread.new do
Chrono::Trigger.new('5 0 * * *') do
registered_tags = Ayaneru.redis.lrange 'tags', 0, -1
registered_tags.each do |tag|
response = Ayaneru.niconico.search(tag, 1)
response.each do |r|
begin
ret = Ayaneru.niconico.reserve(r.contentId)
rescue => exception
puts exception.message
begin
Ayaneru.twitter.create_direct_message(Ayaneru.twitter.user.id, "これ以上タイムシフト予約できません.『#{r.title}』(#{r.url})")
rescue => exception
puts exception.message
end
end
begin
Ayaneru.twitter.create_direct_message(Ayaneru.twitter.user.id, "『#{r.title}』(#{r.url})をタイムシフト予約しました.") if ret
rescue => exception
puts exception.message
end
end
end
end.run
end