ruboty-chinachu 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +9 -0
- data/lib/ruboty/chinachu/actions/base.rb +1 -1
- data/lib/ruboty/chinachu/actions/program.rb +38 -0
- data/lib/ruboty/chinachu/actions/schedule.rb +29 -0
- data/lib/ruboty/chinachu/version.rb +1 -1
- data/lib/ruboty/handlers/chinachu.rb +27 -6
- data/ruboty-chinachu.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c409097b57434086036dda5a7450d76ac1011b40
|
4
|
+
data.tar.gz: 4fb1a2c12d52b89ef071e1cd5826a0e2f803dc1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06988a0e7c82c3f8a598362e9771e7a8bb06c05ca9746ded828a852d709734d02f66c6c9551ace8a5d74cc6e8efaf537dd4f56041cd55fb58776951f7bdfb50d
|
7
|
+
data.tar.gz: 55c8e068e5f0caa5ecc89dbc07b4c9d9ca9a45128805c1974739d5b0961b086d828ec403c5286b41aace46a4bad8b22a6abf974098461a142a6eb30c2d124f68
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
|
3
|
+
Feature
|
4
|
+
|
5
|
+
- Show channel list
|
6
|
+
- Show channel program schedule list
|
7
|
+
- Reserve program
|
8
|
+
- Delete reservation
|
9
|
+
|
10
|
+
Fix
|
11
|
+
|
12
|
+
- Turn capitals the first letter of a sentene
|
13
|
+
- Require Goraku up to 0.1.2
|
14
|
+
|
15
|
+
# 0.1.0
|
16
|
+
|
17
|
+
First release
|
data/README.md
CHANGED
@@ -16,6 +16,15 @@ And then execute:
|
|
16
16
|
|
17
17
|
$ bundle install
|
18
18
|
|
19
|
+
## ENV
|
20
|
+
|
21
|
+
```shell
|
22
|
+
CHINACHU_API_ENDPOINT - API endpont address you Chinachu server
|
23
|
+
CHINACHU_LOGIN - BASIC login name (Option: if you use BASIC Auth)
|
24
|
+
CHINACHU_PASSWORD - BASIC login pass (Option: if you use BASIC Auth)
|
25
|
+
CHINACHU_PROGRAM_FORMAT - Output program summary format string
|
26
|
+
```
|
27
|
+
|
19
28
|
## Usage
|
20
29
|
|
21
30
|
```shell
|
@@ -10,7 +10,7 @@ module Ruboty
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def chinachu_options
|
13
|
-
opts = {api_endpoint: ENV['CHINACHU_API_ENDPOINT']}
|
13
|
+
opts = {api_endpoint: ENV['CHINACHU_API_ENDPOINT'], raise_error: true}
|
14
14
|
return opts unless ENV['CHINACHU_LOGIN'] || ENV['CHINACHU_PASSWORD']
|
15
15
|
opts[:login] = ENV['CHINACHU_LOGIN']
|
16
16
|
opts[:password] = ENV['CHINACHU_PASSWORD']
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Chinachu
|
3
|
+
module Actions
|
4
|
+
class Program < Base
|
5
|
+
|
6
|
+
def reserve
|
7
|
+
begin
|
8
|
+
chinachu.reserve_program(program_id)
|
9
|
+
program = chinachu.program(program_id)
|
10
|
+
message.reply("Reserved #{summary(program, PROGRAM_FORMAT)}")
|
11
|
+
rescue Goraku::Status409
|
12
|
+
message.reply("Id #{program_id} already reserved")
|
13
|
+
rescue
|
14
|
+
message.reply("Reserve #{program_id} faild")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete_reservation
|
19
|
+
begin
|
20
|
+
program = chinachu.reserves_program(program_id)
|
21
|
+
chinachu.delete_reserved_program(program_id)
|
22
|
+
message.reply("Delete reservation #{summary(program, PROGRAM_FORMAT)}")
|
23
|
+
rescue Goraku::Status404
|
24
|
+
message.reply("Id #{program_id} is not reserved")
|
25
|
+
rescue
|
26
|
+
message.reply("Delete reservation #{program_id} faild")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def program_id
|
33
|
+
message[:program_id]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -8,11 +8,40 @@ module Ruboty
|
|
8
8
|
message.reply(broadcasting.map { |p| summary(p, PROGRAM_FORMAT) }.join("\n"), code: true)
|
9
9
|
end
|
10
10
|
|
11
|
+
def list_channels
|
12
|
+
message.reply(channels.join("\n"), code: true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_schedule
|
16
|
+
current = Time.now
|
17
|
+
after_twenty_four_hour = current + (60 * 60 * 24)
|
18
|
+
begin
|
19
|
+
programs = schedules.select do |program|
|
20
|
+
start_at = Time.at(program.start / 1000)
|
21
|
+
current < start_at && start_at < after_twenty_four_hour
|
22
|
+
end
|
23
|
+
message.reply(programs.map { |p| summary(p, PROGRAM_FORMAT) }.join("\n"), code: true)
|
24
|
+
rescue
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
11
28
|
private
|
12
29
|
|
13
30
|
def broadcasting
|
14
31
|
chinachu.schedule_broadcasting
|
15
32
|
end
|
33
|
+
|
34
|
+
def channels
|
35
|
+
chinachu.schedule.map { |s| "id:#{s.id} - #{s.name}" }
|
36
|
+
end
|
37
|
+
|
38
|
+
def schedules
|
39
|
+
chinachu.schedule_channel_programs(channel_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def channel_id
|
43
|
+
message[:channel_id]
|
44
|
+
end
|
16
45
|
end
|
17
46
|
end
|
18
47
|
end
|
@@ -2,20 +2,25 @@ require 'ruboty/chinachu/actions/reserves'
|
|
2
2
|
require 'ruboty/chinachu/actions/schedule'
|
3
3
|
require 'ruboty/chinachu/actions/recording'
|
4
4
|
require 'ruboty/chinachu/actions/recorded'
|
5
|
+
require 'ruboty/chinachu/actions/program'
|
5
6
|
|
6
7
|
module Ruboty
|
7
8
|
module Handlers
|
8
9
|
class Chinachu < Ruboty::Handlers::Base
|
9
10
|
|
10
|
-
env :CHINACHU_API_ENDPOINT, "
|
11
|
+
env :CHINACHU_API_ENDPOINT, "Chinachu api endpoint"
|
11
12
|
env :CHINACHU_LOGIN, "Login name for Chinachu server's basic authentication", optional: true
|
12
13
|
env :CHINACHU_PASSWORD, "Login pass for Chinachu server's basic authentication", optional: true
|
13
|
-
env :CHINACHU_PROGRAM_FORMAT, "
|
14
|
+
env :CHINACHU_PROGRAM_FORMAT, "Program output string format", optional: true
|
14
15
|
|
15
|
-
on( /list reserved/, name: :daily_reservation_list, description: "
|
16
|
-
on( /list broadcasting/, name: :list_broadcasting, description: "
|
17
|
-
on( /list recording/, name: :list_recording, description: "
|
18
|
-
on( /list recorded/, name: :list_recorded, description: "
|
16
|
+
on( /list reserved/, name: :daily_reservation_list, description: "Show today's reservations list")
|
17
|
+
on( /list broadcasting/, name: :list_broadcasting, description: "Broadcasting programs")
|
18
|
+
on( /list recording/, name: :list_recording, description: "Recording programs")
|
19
|
+
on( /list recorded/, name: :list_recorded, description: "Recorded programs in this 24 hours")
|
20
|
+
on( /list channel/, name: :list_channel, description: "Show all channel list")
|
21
|
+
on( /list program schedule (?<channel_id>.+)/, name: :list_schedule, description: "Show today's channel schedule")
|
22
|
+
on( /reserve program (?<program_id>.+)/, name: :reserve, description: "Reserve Program")
|
23
|
+
on( /delete reservation (?<program_id>.+)/, name: :delete_reservation, description: "Delete reserved Program")
|
19
24
|
|
20
25
|
def daily_reservation_list(message)
|
21
26
|
Ruboty::Chinachu::Actions::Reserves.new(message).call
|
@@ -32,6 +37,22 @@ module Ruboty
|
|
32
37
|
def list_recorded(message)
|
33
38
|
Ruboty::Chinachu::Actions::Recorded.new(message).call
|
34
39
|
end
|
40
|
+
|
41
|
+
def list_channel(message)
|
42
|
+
Ruboty::Chinachu::Actions::Schedule.new(message).list_channels
|
43
|
+
end
|
44
|
+
|
45
|
+
def list_schedule(message)
|
46
|
+
Ruboty::Chinachu::Actions::Schedule.new(message).list_schedule
|
47
|
+
end
|
48
|
+
|
49
|
+
def reserve(message)
|
50
|
+
Ruboty::Chinachu::Actions::Program.new(message).reserve
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete_reservation(message)
|
54
|
+
Ruboty::Chinachu::Actions::Program.new(message).delete_reservation
|
55
|
+
end
|
35
56
|
end
|
36
57
|
end
|
37
58
|
end
|
data/ruboty-chinachu.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_runtime_dependency "ruboty", "~> 1.2"
|
20
|
-
spec.add_runtime_dependency "goraku", "~> 0.
|
20
|
+
spec.add_runtime_dependency "goraku", "~> 0.1.2"
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.10"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-chinachu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinoshita.Yasuhiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.1.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
120
|
- ".travis.yml"
|
121
|
+
- CHANGELOG.md
|
121
122
|
- CODE_OF_CONDUCT.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.md
|
@@ -125,6 +126,7 @@ files:
|
|
125
126
|
- Rakefile
|
126
127
|
- lib/ruboty/chinachu.rb
|
127
128
|
- lib/ruboty/chinachu/actions/base.rb
|
129
|
+
- lib/ruboty/chinachu/actions/program.rb
|
128
130
|
- lib/ruboty/chinachu/actions/recorded.rb
|
129
131
|
- lib/ruboty/chinachu/actions/recording.rb
|
130
132
|
- lib/ruboty/chinachu/actions/reserves.rb
|