Class: Ruboty::Actions::OpeningSentence
- Inherits:
-
Object
- Object
- Ruboty::Actions::OpeningSentence
- Defined in:
- lib/ruboty/actions/opening_sentence.rb
Constant Summary collapse
- AOZORA_RANDOM_BOOK_URL =
'http://aozora-api.herokuapp.com/books/random.json'
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ruboty/actions/opening_sentence.rb', line 9 def call json = open(AOZORA_RANDOM_BOOK_URL).read rescue return book = JSON.parse(json) rescue return = [ "@#{.from_name}", "作品名: #{book['title']}", book['opening_sentence'], book['url'] ].join($/) .reply() end |