ruboty-chinachu 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.md +14 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/lib/ruboty/chinachu.rb +12 -0
- data/lib/ruboty/chinachu/actions/base.rb +40 -0
- data/lib/ruboty/chinachu/actions/recorded.rb +25 -0
- data/lib/ruboty/chinachu/actions/recording.rb +16 -0
- data/lib/ruboty/chinachu/actions/reserves.rb +27 -0
- data/lib/ruboty/chinachu/actions/schedule.rb +19 -0
- data/lib/ruboty/chinachu/version.rb +5 -0
- data/lib/ruboty/handlers/chinachu.rb +37 -0
- data/ruboty-chinachu.gemspec +26 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0463199552ee7eb3ede9a449364db27a0118d0bc
|
4
|
+
data.tar.gz: feb15bf71cf7e30cca3e81d883d4d435cc8a3dd8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 36f9e88d9621df86694df93a7bdc30826364c71039dedaf1ba0b9b6932c8173e8e1df33b428633dfb660e8096e7df7b5e6e2999ceab290490c5737013c778854
|
7
|
+
data.tar.gz: 55771aea50111cc9be1d87bd47369304f5653e4dcac636d52f0b927eac65fcceb9c5f439e0b17edd8c7efa10bdb854f59453b910e4119587f5644ff0a129c4b7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
3
|
+
|
4
|
+
Copyright (C) 2015 Yasuhiro Kinoshita <WhoIsDissolvedGirl+github@gmail.com>
|
5
|
+
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
7
|
+
copies of this license document, and changing it is allowed as long
|
8
|
+
as the name is changed.
|
9
|
+
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Ruboty::Chinachu
|
2
|
+
|
3
|
+
Ruboty plugin work with Chinachu server(nam://chinachu.moe/)
|
4
|
+
|
5
|
+
This plugin inform you what program reserved and recorded
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your Ruboty's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruboty-chinachu'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```shell
|
22
|
+
ruboty list reserved # show reserved programs list in this 24 hours
|
23
|
+
ruboty list broadcasting # show broadcasting programs list
|
24
|
+
ruboty list recording # shwo now recording programs list
|
25
|
+
ruboty list recorded # show recorded programs list in this 24 hours
|
26
|
+
```
|
27
|
+
|
28
|
+
## LICENSE
|
29
|
+
|
30
|
+
WTFPL
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruboty-chinachu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
35
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Chinachu
|
3
|
+
module Actions
|
4
|
+
class Base < Ruboty::Actions::Base
|
5
|
+
|
6
|
+
PROGRAM_FORMAT = ENV['CHINACHU_PROGRAM_FORMAT'] || '%title% #%episode%(%id%) %start% - %end%'
|
7
|
+
|
8
|
+
def chinachu
|
9
|
+
@chinachu ||= Goraku::Client.new(chinachu_options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def chinachu_options
|
13
|
+
opts = {api_endpoint: ENV['CHINACHU_API_ENDPOINT']}
|
14
|
+
return opts unless ENV['CHINACHU_LOGIN'] || ENV['CHINACHU_PASSWORD']
|
15
|
+
opts[:login] = ENV['CHINACHU_LOGIN']
|
16
|
+
opts[:password] = ENV['CHINACHU_PASSWORD']
|
17
|
+
opts
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def summary(program, format)
|
23
|
+
|
24
|
+
formatted = program.to_h.each_pair.inject(format) do |acc, pair|
|
25
|
+
replace_key_val(acc, pair.first.to_s, pair.last.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
program.channel.to_h.each_pair.inject(formatted) do |acc, pair|
|
29
|
+
replace_key_val(acc, pair.first.to_s, pair.last.to_s)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def replace_key_val(format, key, val)
|
34
|
+
val = Time.at(val.to_i / 1000).strftime("%F %R") if key == 'start' || key =='end'
|
35
|
+
format.gsub("%#{key}%", val)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Chinachu
|
3
|
+
module Actions
|
4
|
+
class Recorded < Base
|
5
|
+
|
6
|
+
def call
|
7
|
+
message.reply(list_recorded_yesterday.map { |r| summary(r, PROGRAM_FORMAT) }.join("\n"), code: true)
|
8
|
+
end
|
9
|
+
|
10
|
+
def list_recorded_yesterday
|
11
|
+
current = Time.now
|
12
|
+
before_twenty_four_hour = current - (60 * 60 * 24)
|
13
|
+
recorded.select do |program|
|
14
|
+
record_end_at = Time.at(program.end / 1000)
|
15
|
+
before_twenty_four_hour < record_end_at && record_end_at < current
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def recorded
|
20
|
+
chinachu.recorded
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Chinachu
|
3
|
+
module Actions
|
4
|
+
class Reserves < Base
|
5
|
+
|
6
|
+
def call
|
7
|
+
message.reply(todays_reservation_list.map { |r| summary(r, PROGRAM_FORMAT) }.join("\n"), code: true)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def todays_reservation_list
|
13
|
+
current = Time.now
|
14
|
+
after_twenty_four_hour = current + (60 * 60 * 24)
|
15
|
+
reservation_list.select do |program|
|
16
|
+
record_start_at = Time.at(program.start / 1000)
|
17
|
+
current < record_start_at && record_start_at < after_twenty_four_hour
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def reservation_list
|
22
|
+
chinachu.reserves
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Chinachu
|
3
|
+
module Actions
|
4
|
+
class Schedule < Base
|
5
|
+
|
6
|
+
|
7
|
+
def list_broadcasting
|
8
|
+
message.reply(broadcasting.map { |p| summary(p, PROGRAM_FORMAT) }.join("\n"), code: true)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def broadcasting
|
14
|
+
chinachu.schedule_broadcasting
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'ruboty/chinachu/actions/reserves'
|
2
|
+
require 'ruboty/chinachu/actions/schedule'
|
3
|
+
require 'ruboty/chinachu/actions/recording'
|
4
|
+
require 'ruboty/chinachu/actions/recorded'
|
5
|
+
|
6
|
+
module Ruboty
|
7
|
+
module Handlers
|
8
|
+
class Chinachu < Ruboty::Handlers::Base
|
9
|
+
|
10
|
+
env :CHINACHU_API_ENDPOINT, "chinachu api endpoint"
|
11
|
+
env :CHINACHU_LOGIN, "Login name for Chinachu server's basic authentication", optional: true
|
12
|
+
env :CHINACHU_PASSWORD, "Login pass for Chinachu server's basic authentication", optional: true
|
13
|
+
env :CHINACHU_PROGRAM_FORMAT, "program output string format", optional: true
|
14
|
+
|
15
|
+
on( /list reserved/, name: :daily_reservation_list, description: "show today's reservations list")
|
16
|
+
on( /list broadcasting/, name: :list_broadcasting, description: "broadcasting programs")
|
17
|
+
on( /list recording/, name: :list_recording, description: "recording programs")
|
18
|
+
on( /list recorded/, name: :list_recorded, description: "recorded programs in this 24 hours")
|
19
|
+
|
20
|
+
def daily_reservation_list(message)
|
21
|
+
Ruboty::Chinachu::Actions::Reserves.new(message).call
|
22
|
+
end
|
23
|
+
|
24
|
+
def list_broadcasting(message)
|
25
|
+
Ruboty::Chinachu::Actions::Schedule.new(message).list_broadcasting
|
26
|
+
end
|
27
|
+
|
28
|
+
def list_recording(message)
|
29
|
+
Ruboty::Chinachu::Actions::Recording.new(message).call
|
30
|
+
end
|
31
|
+
|
32
|
+
def list_recorded(message)
|
33
|
+
Ruboty::Chinachu::Actions::Recorded.new(message).call
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/chinachu/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-chinachu"
|
8
|
+
spec.version = Ruboty::Chinachu::VERSION
|
9
|
+
spec.authors = ["Kinoshita.Yasuhiro"]
|
10
|
+
spec.email = ["WhoIsDissolvedGirl+github@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruboty plugin work with Chinachu server}
|
13
|
+
spec.description = %q{Ruboty plugin work with Chinachu server}
|
14
|
+
spec.homepage = "https://github.com/YasuhiroKinoshita/ruboty-chinachu"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_runtime_dependency "ruboty", "~> 1.2"
|
20
|
+
spec.add_runtime_dependency "goraku", "~> 0.0"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "wtfpl_init"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-chinachu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kinoshita.Yasuhiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: goraku
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: wtfpl_init
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Ruboty plugin work with Chinachu server
|
112
|
+
email:
|
113
|
+
- WhoIsDissolvedGirl+github@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.md
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- lib/ruboty/chinachu.rb
|
127
|
+
- lib/ruboty/chinachu/actions/base.rb
|
128
|
+
- lib/ruboty/chinachu/actions/recorded.rb
|
129
|
+
- lib/ruboty/chinachu/actions/recording.rb
|
130
|
+
- lib/ruboty/chinachu/actions/reserves.rb
|
131
|
+
- lib/ruboty/chinachu/actions/schedule.rb
|
132
|
+
- lib/ruboty/chinachu/version.rb
|
133
|
+
- lib/ruboty/handlers/chinachu.rb
|
134
|
+
- ruboty-chinachu.gemspec
|
135
|
+
homepage: https://github.com/YasuhiroKinoshita/ruboty-chinachu
|
136
|
+
licenses: []
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.4.5
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Ruboty plugin work with Chinachu server
|
158
|
+
test_files: []
|