sentry-titles 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +2 -0
- data/VERSION +1 -0
- data/lib/cinch/plugins/sentry/titles.rb +96 -0
- data/sentry-titles.gemspec +22 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3141cd4913f98524789f16f619ccab6a8bd47baa
|
4
|
+
data.tar.gz: e200db59d2c7cf8a88cef2fbaf3714125a1b219f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a7eac679f5d2878e617749381a0680d7be5aae5f52345b11f017cd4faf1ec7f7ddce31ccc6ca7c7c57d4c5b845de3e7eb6afc719c006406155f46c45acce8118
|
7
|
+
data.tar.gz: f270b65b2dd10200e7fe314ada203d4ef456d5434e243cd03b25f9966ac7d551d55219620198e57d67b9f268bf4fab5464639257361a3ac5f44bcdf62921a7ab
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 jRiddick
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Sentry::Title
|
2
|
+
|
3
|
+
Plugin that parses HTML-titles and sends them to the channel. It blocks some domains that has to be explicitly allowed so not to interfere with plugins that handles those speficic sites.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sentry-title'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sentry-title
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'cinch'
|
25
|
+
require 'cinch/plugins/sentry/titles'
|
26
|
+
|
27
|
+
bot = Cinch::Bot.new do
|
28
|
+
configure do |c|
|
29
|
+
c.nick = "Raknet"
|
30
|
+
c.server = "irc.oftc.net"
|
31
|
+
c.channels = ["#cinchdev"]
|
32
|
+
c.plugins.plugins = [Cinch::Plugins::Sentry::Titles]
|
33
|
+
c.plugins.options = {
|
34
|
+
Cinch::Plugins::Sentry::Titles => {
|
35
|
+
"blacklist" => [
|
36
|
+
"facebook.com"
|
37
|
+
],
|
38
|
+
"whitelist" => [
|
39
|
+
"reddit.com",
|
40
|
+
"www.reddit.com"
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
bot.start
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/[my-github-username]/sentry-title/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'cinch'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'uri'
|
4
|
+
require "open-uri"
|
5
|
+
require "open_uri_redirections"
|
6
|
+
require "twitter-text"
|
7
|
+
require "sentry/helper"
|
8
|
+
|
9
|
+
module Cinch
|
10
|
+
module Plugins
|
11
|
+
module Sentry
|
12
|
+
class Titles
|
13
|
+
include Cinch::Plugin
|
14
|
+
include Twitter::Extractor
|
15
|
+
|
16
|
+
# Listen to all events in the channel
|
17
|
+
listen_to :channel
|
18
|
+
|
19
|
+
def initialize(*)
|
20
|
+
super
|
21
|
+
@bot = bot
|
22
|
+
end
|
23
|
+
|
24
|
+
def listen(m)
|
25
|
+
# Extract urls
|
26
|
+
urls = extract_urls(m.message)
|
27
|
+
|
28
|
+
# Blacklist of urls that are not allowed
|
29
|
+
blacklist = [
|
30
|
+
"redd.it",
|
31
|
+
"www.redd.it",
|
32
|
+
"reddit.com",
|
33
|
+
"www.reddit.com",
|
34
|
+
"www.dailymotion.com",
|
35
|
+
"dailymotion.com",
|
36
|
+
"dai.ly",
|
37
|
+
"www.dai.ly",
|
38
|
+
"vimeo.com",
|
39
|
+
"www.vimeo.com",
|
40
|
+
"www.youtube.com",
|
41
|
+
"youtube.com",
|
42
|
+
"youtu.be",
|
43
|
+
"www.youtu.be",
|
44
|
+
"github.com",
|
45
|
+
"www.github.com"]
|
46
|
+
|
47
|
+
# Build blacklist
|
48
|
+
blacklist.concat(config["blacklist"]) if config.key? "blacklist"
|
49
|
+
|
50
|
+
# List of extensions that are ignored
|
51
|
+
extensions = [
|
52
|
+
".gif",
|
53
|
+
".jpg",
|
54
|
+
".jpeg",
|
55
|
+
".png",
|
56
|
+
".bmp",
|
57
|
+
".js",
|
58
|
+
".rb",
|
59
|
+
".css",
|
60
|
+
".pdf",
|
61
|
+
".gifv"]
|
62
|
+
|
63
|
+
# Build extension list
|
64
|
+
extensions.concat(config["extensions"]) if config.key? "extensions"
|
65
|
+
|
66
|
+
# List of blacklist overrides
|
67
|
+
whitelist = []
|
68
|
+
|
69
|
+
# Build list of overrides
|
70
|
+
whitelist.concat(config["whitelist"]) if config.key? "whitelist"
|
71
|
+
|
72
|
+
# Handle all urls individually
|
73
|
+
urls.each do |url|
|
74
|
+
# Parse the url
|
75
|
+
uri = URI.parse(URI.escape(url.to_url))
|
76
|
+
|
77
|
+
# Skip all blacklisted hosts that are not explicitly allowed
|
78
|
+
next if blacklist.include?(uri.host) and not whitelist.include?(uri.host)
|
79
|
+
|
80
|
+
# Skip all links that leads to files
|
81
|
+
next if extensions.include?(File.extname(uri.path))
|
82
|
+
|
83
|
+
# Load the page
|
84
|
+
page = Nokogiri::HTML(open(url.to_s, :allow_redirections => :all))
|
85
|
+
|
86
|
+
# Send the title to the channel
|
87
|
+
m.reply("[%s] %s" % [
|
88
|
+
Format(:green, "LINK"),
|
89
|
+
Format(:bold, page.css("title")[0].text.strip.gsub(/\n/,"").gsub(/\r/,"").gsub(/\s+/,"\s"))
|
90
|
+
])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "sentry-titles"
|
5
|
+
spec.version = File.new("VERSION", 'r').read.chomp
|
6
|
+
spec.authors = ["jRiddick"]
|
7
|
+
spec.email = ["apersson.93@gmail.com"]
|
8
|
+
spec.summary = %q{Parses HTML-titles and outputs them to the channel}
|
9
|
+
spec.homepage = "https://rubygems.org/gems/sentry-titles"
|
10
|
+
spec.license = "MIT"
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0")
|
13
|
+
spec.require_paths = ["lib"]
|
14
|
+
|
15
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
16
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
17
|
+
|
18
|
+
spec.add_dependency "nokogiri", "~> 1.6"
|
19
|
+
spec.add_dependency "cinch", "~> 2.0"
|
20
|
+
spec.add_dependency "open_uri_redirections", "~> 0.2"
|
21
|
+
spec.add_dependency "twitter-text", "~> 1.13"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sentry-titles
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jRiddick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-07 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: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cinch
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: open_uri_redirections
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: twitter-text
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.13'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.13'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- apersson.93@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- VERSION
|
110
|
+
- lib/cinch/plugins/sentry/titles.rb
|
111
|
+
- sentry-titles.gemspec
|
112
|
+
homepage: https://rubygems.org/gems/sentry-titles
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.5.1
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Parses HTML-titles and outputs them to the channel
|
136
|
+
test_files: []
|