isis-plugin-isup 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/isis-plugin-isup.gemspec +25 -0
- data/lib/isis/plugin/isup.rb +58 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 49b34178fc858af1c4442b4f0389e7c07e178f1e
|
4
|
+
data.tar.gz: f1c85138e75fc0a6b057e3b4c4359f7d98d2d8fa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 663fe5b7bb082fc4f18391992f9ca2560033dee2e6e81a41c0dc9ccd8a12c5123bfa62bf9decd038f57049fa1c9743893cde6795b63bba34535a901179eabd9b
|
7
|
+
data.tar.gz: badc60f32f7b5a320cdd5e5e7217deb3078efb8e9a0f4bebcf57c9dce8cb8bed8a8db3e2dca131f8611de0fb5ee4a8e8c2006194392d8a038d6566436c9696f7
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Isis plugin: Is Up
|
2
|
+
|
3
|
+
This plugin adds a [isup.me](http://www.isup.me) command to the [Isis chatbot](https://github.com/silentgrowl/isis)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your Isis installation's Gemfile:
|
8
|
+
|
9
|
+
``ruby
|
10
|
+
gem 'isis-plugin-isup'
|
11
|
+
``
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
To check if a site is up for everyone, type ```!isup (domain)``` in chat (eg. ```!isup www.google.com```)
|
20
|
+
|
21
|
+
## Links
|
22
|
+
|
23
|
+
* [isis-plugin-isup on RubyGems](https://rubygems.org/gems/isis-plugin-isup)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "isis/plugin/isup"
|
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/bin/setup
ADDED
@@ -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
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "isis-plugin-isup"
|
7
|
+
spec.version = "1.0.0"
|
8
|
+
spec.authors = ["Brendon Rapp"]
|
9
|
+
spec.email = ["brendon@silentgrowl.com"]
|
10
|
+
spec.license = 'MIT'
|
11
|
+
|
12
|
+
spec.summary = %q{Isis plugin: Is Up}
|
13
|
+
spec.description = %q{Isis plugin: Is Up}
|
14
|
+
spec.homepage = "https://github.com/silentgrowl/isis-plugin-isup"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "nokogiri"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Isis
|
4
|
+
module Plugin
|
5
|
+
class IsUp < Isis::Plugin::Base
|
6
|
+
DOMAIN_REGEX = /^[a-z0-9]+([\-]{1}[a-z0-9]+)*\.[a-z]{2,5}$/ix
|
7
|
+
SLACK_REGEX = /^<http:\/\/(?<url>[a-zA-Z\/\.:]+\w)\|/
|
8
|
+
|
9
|
+
def respond_to_msg?(msg, speaker)
|
10
|
+
@commands = msg.downcase.split
|
11
|
+
@commands[0] == '!isup'
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def response_html
|
17
|
+
response = scrape(@commands[1])
|
18
|
+
return %Q(Sorry, I can't process that name) unless response
|
19
|
+
if response =~ /It's just you/
|
20
|
+
"#{@commands[1]} appears to be up. All good."
|
21
|
+
else
|
22
|
+
"#{@commands[1]} appears to be <b>down</b>! Panic!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def response_md
|
27
|
+
cleaned_domain = SLACK_REGEX.match(@commands[1])[:url] # Slack auto-linkifies domains, rewrite cleaned domain
|
28
|
+
response = scrape(cleaned_domain)
|
29
|
+
return %Q(Sorry, I can't process that name) unless response
|
30
|
+
if response =~ /It's just you/
|
31
|
+
"#{cleaned_domain} appears to be up. All good."
|
32
|
+
else
|
33
|
+
"#{cleaned_domain} appears to be *down*! Panic!"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def response_text
|
38
|
+
response = scrape(@commands[1])
|
39
|
+
return %Q(Sorry, I can't process that name) unless response
|
40
|
+
if response =~ /It's just you/
|
41
|
+
"#{@commands[1]} appears to be up. All good."
|
42
|
+
else
|
43
|
+
"#{@commands[1]} appears to be down! Panic!"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def scrape(domain)
|
48
|
+
domain = domain.split('www.')[1] if /www\./.match(domain)
|
49
|
+
if DOMAIN_REGEX.match(domain)
|
50
|
+
page = Nokogiri.HTML(open("http://isup.me/#{domain}"))
|
51
|
+
page.css('#container').text
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isis-plugin-isup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brendon Rapp
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: 'Isis plugin: Is Up'
|
56
|
+
email:
|
57
|
+
- brendon@silentgrowl.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- isis-plugin-isup.gemspec
|
70
|
+
- lib/isis/plugin/isup.rb
|
71
|
+
homepage: https://github.com/silentgrowl/isis-plugin-isup
|
72
|
+
licenses:
|
73
|
+
- MIT
|
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: 'Isis plugin: Is Up'
|
95
|
+
test_files: []
|
96
|
+
has_rdoc:
|