ruboty-monday_is_coming 0.2.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/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/lib/ruboty-monday_is_coming/version.rb +5 -0
- data/lib/ruboty/handlers/monday_is_coming.rb +87 -0
- data/lib/ruboty/monday_is_coming.rb +2 -0
- data/ruboty-monday_is_coming.gemspec +25 -0
- data/script/console +14 -0
- data/script/setup +7 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aae4404a4145a4544690f72f938dc77176d1824b
|
4
|
+
data.tar.gz: 12e55a05f8fbd9225dc638ecdc0173b1bb1e6d49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3eb5b6ce6084fd6bc68e1bb758d826fea59f2a1edb42ad33d433114aa83b22d9dd7d1c31f44de671e47f0cf0b28d3c121ec3099a3dfd2ae2c5947f208d6d902
|
7
|
+
data.tar.gz: fbb73d44f3dd9579b0b64589b311c992df387610e4aa1766b0fa71faf2f102ae5e878d73813569b68cd697a4fca89e96d7b5a4f710633010261be1c6bce970c3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Ruboty::MondayIsComing
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruboty/monday_is_coming`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruboty-monday_is_coming'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruboty-monday_is_coming
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/ruboty-monday_is_coming/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'ruboty/handlers/base'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'uri'
|
5
|
+
require 'csv'
|
6
|
+
require 'time'
|
7
|
+
|
8
|
+
module Ruboty
|
9
|
+
module Handlers
|
10
|
+
class MondayIsComing < Base
|
11
|
+
on(/月曜日?(?:よりの使者)?/, name: 'show', description: '日高愛ちゃん')
|
12
|
+
on(/monday(?:\s+is\s+coming)?/, name: 'show', description: '日高愛ちゃん')
|
13
|
+
|
14
|
+
CACHE_TTL = 120
|
15
|
+
def initialize(*)
|
16
|
+
super
|
17
|
+
@illusts_cache = nil
|
18
|
+
@illusts_cached_at = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def show(message)
|
22
|
+
message.reply image_url
|
23
|
+
rescue Exception => e
|
24
|
+
message.reply "#{e.inspect}\n\t#{e.backtrace.join("\n\t")}"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def image_url
|
30
|
+
time = Time.now
|
31
|
+
illust = if time.monday?
|
32
|
+
beg = Time.local(time.year, time.month, time.day, 0, 0, 0, '+09:00')
|
33
|
+
illusts.select { |_| _[:uploaded_at] >= beg }.min || illusts.sample
|
34
|
+
else
|
35
|
+
illusts.sample
|
36
|
+
end
|
37
|
+
illust[:mobile_thumbnail_max_width_480]
|
38
|
+
end
|
39
|
+
|
40
|
+
def illusts
|
41
|
+
if !@illusts_cache || (Time.now - @illusts_cached_at) > CACHE_TTL
|
42
|
+
@illusts_cache = illusts_without_cache()
|
43
|
+
@illusts_cached_at = Time.now
|
44
|
+
end
|
45
|
+
@illusts_cache
|
46
|
+
end
|
47
|
+
|
48
|
+
PIXIV_TARGET_TAG = "月曜日よりの使者"
|
49
|
+
PIXIV_TARGET_AUTHOR_ID = "2493100"
|
50
|
+
def illusts_without_cache
|
51
|
+
pixiv_search_tag(PIXIV_TARGET_TAG).select { |_| _[:user_id] == PIXIV_TARGET_AUTHOR_ID }
|
52
|
+
end
|
53
|
+
|
54
|
+
PIXIV_SPAPI_SEARCH_TAG_URL = 'http://spapi.pixiv.net/iphone/search.php?s_mode=s_tag&word=%s'
|
55
|
+
def pixiv_search_tag(tag)
|
56
|
+
result = open(PIXIV_SPAPI_SEARCH_TAG_URL % [URI.encode_www_form_component(tag)], 'r', &:read)
|
57
|
+
lines = CSV.parse(result)
|
58
|
+
lines.map do |line|
|
59
|
+
{
|
60
|
+
id: line[0],
|
61
|
+
user_id: line[1],
|
62
|
+
extension: line[2],
|
63
|
+
image_title: line[3],
|
64
|
+
image_directory: line[4],
|
65
|
+
artist_nickname: line[5],
|
66
|
+
mobile_thumbnail_128_url: line[6],
|
67
|
+
mobile_thumbnail_max_width_480: line[9],
|
68
|
+
uploaded_at: Time.parse(line[12] + ' +09:00'),
|
69
|
+
tags: line[13],
|
70
|
+
software: line[14],
|
71
|
+
ratings_count: line[15],
|
72
|
+
score: line[16],
|
73
|
+
views: line[17],
|
74
|
+
image_description: line[18],
|
75
|
+
pages_count: line[19],
|
76
|
+
favorites_count: line[22],
|
77
|
+
comments_count: line[23],
|
78
|
+
artist_username: line[24],
|
79
|
+
r18: line[26],
|
80
|
+
series_id: line[27],
|
81
|
+
mobile_profile_image: line[29],
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty-monday_is_coming/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-monday_is_coming"
|
8
|
+
spec.version = Ruboty::MondayIsComing::VERSION
|
9
|
+
spec.authors = ["Shota Fukumori (sora_h)"]
|
10
|
+
spec.email = ["her@sorah.jp"]
|
11
|
+
|
12
|
+
spec.summary = %q{ruboty monday is coming}
|
13
|
+
spec.homepage = "https://github.com/sorah/ruboty-monday_is_coming"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "bin"
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
|
23
|
+
spec.add_dependency "ruboty"
|
24
|
+
# spec.add_dependency "nokogiri"
|
25
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruboty/monday_is_coming"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/script/setup
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-monday_is_coming
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shota Fukumori (sora_h)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruboty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- her@sorah.jp
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/ruboty-monday_is_coming/version.rb
|
67
|
+
- lib/ruboty/handlers/monday_is_coming.rb
|
68
|
+
- lib/ruboty/monday_is_coming.rb
|
69
|
+
- ruboty-monday_is_coming.gemspec
|
70
|
+
- script/console
|
71
|
+
- script/setup
|
72
|
+
homepage: https://github.com/sorah/ruboty-monday_is_coming
|
73
|
+
licenses: []
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.2.2
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: ruboty monday is coming
|
95
|
+
test_files: []
|