cinch-haiku 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +34 -0
- data/lib/cinch/plugins/haiku.rb +26 -0
- metadata +72 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2012 by Dominik Honnef
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
TODO: write description, check class name, list commands, list options
|
2
|
+
# Daiku plugin
|
3
|
+
|
4
|
+
Fetches a random haiku from dailyhaiku.org and displays it.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
First install the gem by running:
|
8
|
+
```
|
9
|
+
[sudo] gem install cinch-haiku
|
10
|
+
```
|
11
|
+
|
12
|
+
Then load it in your bot:
|
13
|
+
```ruby
|
14
|
+
require "cinch"
|
15
|
+
require "cinch/plugins/haiku"
|
16
|
+
|
17
|
+
bot = Cinch::Bot.new do
|
18
|
+
configure do |c|
|
19
|
+
# add all required options here
|
20
|
+
c.plugins.plugins = [Cinch::Plugins::Haiku]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
bot.start
|
25
|
+
```
|
26
|
+
## Commands
|
27
|
+
|
28
|
+
```
|
29
|
+
haiku
|
30
|
+
```
|
31
|
+
|
32
|
+
## Options
|
33
|
+
### :delay
|
34
|
+
Add a delay of N seconds between each line of the haiku.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module Cinch
|
5
|
+
module Plugins
|
6
|
+
class Haiku
|
7
|
+
include Cinch::Plugin
|
8
|
+
|
9
|
+
match "haiku"
|
10
|
+
def execute(m)
|
11
|
+
html = Nokogiri::HTML(open("http://www.dailyhaiku.org/haiku/?pg=#{rand(220) + 1}"))
|
12
|
+
haikus = html.search('p.haiku').to_a
|
13
|
+
haiku_lines = haikus.sample.text.split(/[\r\n]+/)
|
14
|
+
|
15
|
+
width = haiku_lines.inject(0) { |max, line|
|
16
|
+
[line.length, max].max
|
17
|
+
}
|
18
|
+
|
19
|
+
haiku_lines.each do |line|
|
20
|
+
sleep config[:delay] if config[:delay]
|
21
|
+
m.reply(' ' + line.center(width))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-haiku
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dominik Honnef
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cinch
|
16
|
+
requirement: &18655180 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *18655180
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &18653720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *18653720
|
36
|
+
description: A plugin providing haikus.
|
37
|
+
email:
|
38
|
+
- dominikh@fork-bomb.org
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- LICENSE
|
44
|
+
- README.md
|
45
|
+
- lib/cinch/plugins/haiku.rb
|
46
|
+
homepage: http://rubydoc.info/github/cinchrb/cinch-haiku
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.1
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.15
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: A plugin providing haikus.
|
71
|
+
test_files: []
|
72
|
+
has_rdoc:
|