Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Send an IRC message to a zenircbot if configured for the account

  • Loading branch information...
commit 3bd8605b096192e9d1466ca4187392b080fb0295 1 parent ba426fd
@aaronpk authored
View
1  Gemfile
@@ -23,6 +23,7 @@ gem 'omniauth-openid'
gem 'mechanize'
gem 'pingback'
gem 'xml-simple', :require => 'xmlsimple'
+gem 'rest-client'
gem 'mysql2', '0.3.7'
gem 'dm-core'
View
3  Gemfile.lock
@@ -101,6 +101,8 @@ GEM
unicorn (~> 4.1)
raindrops (0.8.0)
rake (0.9.2.2)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
ruby-openid (2.1.8)
shotgun (0.9)
rack (>= 1.0)
@@ -161,6 +163,7 @@ DEPENDENCIES
pingback
rainbows
rake
+ rest-client
shotgun
sinatra
sinatra-namespace
View
16 controllers/pingback.rb
@@ -62,12 +62,26 @@ def pingback_ping(args)
valid = scraper.link_with(:href => target) != nil
+ if !site.account.zenircbot_uri.empty? and !site.irc_channel.empty? and valid
+ message = "[pingback] #{source} linked to #{target}"
+
+ uri = "#{site.account.zenircbot_uri}#{URI.encode_www_form_component site.irc_channel}"
+
+ begin
+ puts RestClient.post uri, {
+ message: message
+ }
+ rescue
+ # noop
+ end
+ end
+
if valid
link.verified = true
link.save
rpc_respond 200, "Pingback from #{source} to #{target} was successful! Keep the web talking!"
else
- rpc_error 200, 0x0011, "There appears to be no link to us!"
+ rpc_error 200, 0x0011, "There appears to be no link to this page!"
end
# See http://www.hixie.ch/specs/pingback/pingback for a list of error codes to return
View
0  helpers/blank.rb → helpers/empty.rb
File renamed without changes
View
1  models/account.rb
@@ -8,6 +8,7 @@ class Account
has n, :sites
property :token, String, :length => 255
+ property :zenircbot_uri, String, :length => 255
property :created_at, DateTime
property :updated_at, DateTime
View
1  models/site.rb
@@ -7,6 +7,7 @@ class Site
belongs_to :account
has n, :pages
property :public_access, Boolean, :default => false
+ property :irc_channel, String, :length => 255
property :created_at, DateTime
property :updated_at, DateTime
View
2  views/index.erb
@@ -4,7 +4,7 @@
<br /><br />
<div class="hero-unit">
- <h1>Pingback</h1>
+ <h1>Pingback.me</h1>
<p>
Pingback.me is a pingback API created to easily support pingbacks on any web page. Currently it is not open for signups, but you can <a href="https://github.com/aaronpk/Pingback">download the source code</a> and run it on your own server.
</p>
View
2  views/layout.erb
@@ -43,7 +43,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/dashboard">Pingback</a>
+ <a class="brand" href="/dashboard">Pingback.me</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="/dashboard">Dashboard</a></li>
Please sign in to comment.
Something went wrong with that request. Please try again.