cinch-title 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Victor Bergöö
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,29 @@
1
+ = cinch-title
2
+
3
+ A plugin for the Cinch ircbot framework to output HTML-titles for URL:s posted to the channels.
4
+
5
+ == Usage
6
+
7
+ bot = Cinch::Bot.new do
8
+ configure do |c|
9
+ c.nick = "HTMLBot"
10
+ c.server = "irc.freenode.org"
11
+ c.channels = ["#cinchbots"]
12
+ c.plugins.plugins = [Cinch::Plugins::Netfeed::HTMLTitle]
13
+ c.plugins.options = {
14
+ Cinch::Plugins::Netfeed::HTMLTitle => {
15
+ "ignore" => [
16
+ "facebook.com"
17
+ ]
18
+ }
19
+ }
20
+ end
21
+ end
22
+
23
+ === Options
24
+
25
+ ignore: a list of regexps of URI:S that should be ignored
26
+
27
+ == Copyright
28
+
29
+ Copyright (c) 2010 Victor Bergöö. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "cinch-title"
9
+ gem.summary = %Q{Plugin for Cinch to output HTML-titles}
10
+ gem.description = %Q{Plugin for the irc-framework Cinch to output HTML-titles}
11
+ gem.email = "victor.bergoo@gmail.com"
12
+ gem.homepage = "http://github.com/netfeed/cinch-title"
13
+ gem.authors = ["Victor Bergöö"]
14
+ gem.add_dependency "cinch"
15
+ gem.add_dependency "nokogiri"
16
+ gem.add_dependency "httpclient"
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/cinch-title ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2010 Victor Bergöö
4
+ # This program is made available under the terms of the MIT License.
5
+
6
+ require 'rubygems'
7
+ require File.expand_path('../../lib/cinch-title', __FILE__)
8
+
9
+ bot = Cinch::Bot.new do
10
+ configure do |c|
11
+ c.nick = "HTMLBot"
12
+ c.server = "irc.freenode.org"
13
+ c.channels = ["#cinchbots"]
14
+ c.plugins.plugins = [Cinch::Plugins::Netfeed::HTMLTitle]
15
+ end
16
+ end
17
+
18
+ bot.start
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2010 Victor Bergöö
4
+ # This program is made available under the terms of the MIT License.
5
+
6
+ require 'cinch'
7
+ require 'nokogiri'
8
+ require 'httpclient'
9
+ require 'uri'
10
+
11
+ module Cinch
12
+ module Plugins
13
+ module Netfeed
14
+ class HTMLTitle
15
+ include Cinch::Plugin
16
+
17
+ match /(.*http.*)/, :use_prefix => false
18
+
19
+ def execute m, message
20
+ suffix = m.user.nick[-1] == 's' ? "'" : "'s"
21
+ ignore = config["ignore"] || []
22
+
23
+ URI.extract(message) do |uri|
24
+ begin
25
+ ignore.each do |re|
26
+ raise ArgumentError.new "dang it" if uri =~ /#{re}/
27
+ end
28
+
29
+ m.reply "#{m.user.nick}#{suffix} URL: #{parse(uri)}"
30
+ rescue ArgumentError => e
31
+ next
32
+ rescue URI::InvalidURIError => e
33
+ m.reply "invalid url: #{uri}"
34
+ end
35
+ end
36
+ end
37
+
38
+ def parse uri
39
+ client = HTTPClient.new
40
+ resp = client.get(uri)
41
+
42
+ html = Nokogiri::HTML(resp.content)
43
+ html.xpath("//head/title").first.content
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-title
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - "Victor Berg\xC3\xB6\xC3\xB6"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-24 00:00:00 +02:00
18
+ default_executable: cinch-title
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cinch
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: httpclient
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id003
59
+ description: Plugin for the irc-framework Cinch to output HTML-titles
60
+ email: victor.bergoo@gmail.com
61
+ executables:
62
+ - cinch-title
63
+ extensions: []
64
+
65
+ extra_rdoc_files:
66
+ - LICENSE
67
+ - README.rdoc
68
+ files:
69
+ - .gitignore
70
+ - LICENSE
71
+ - README.rdoc
72
+ - Rakefile
73
+ - VERSION
74
+ - bin/cinch-title
75
+ - lib/cinch-title.rb
76
+ has_rdoc: true
77
+ homepage: http://github.com/netfeed/cinch-title
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --charset=UTF-8
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Plugin for Cinch to output HTML-titles
108
+ test_files: []
109
+