forked from evanphx/irccat
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched Send and Github class into different files. Now can disable …
…http Send, removed http index
- Loading branch information
Showing
4 changed files
with
36 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'json' | ||
require 'json/add/rails' | ||
|
||
class Github < Mongrel::HttpHandler | ||
|
||
def initialize(bot, config); @bot = bot; @config = config; puts "Github enabled"; end | ||
|
||
def process(request, response) | ||
response.start(200) do |head,out| | ||
head["Content-Type"] = "text/plain" | ||
post = CGI.parse(request.body.read) | ||
json = JSON.parse(post['payload'].join(',')) | ||
json['commits'].each do |c| | ||
@bot.say(@config['irc']['channel'],"[#{json['repository']['name']}] New commit by #{c.last['author']['name']} : #{c.last['message'].gsub(/\n(.*)/, '...')} - #{c.last['url']}") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Send < Mongrel::HttpHandler | ||
|
||
def initialize(bot, config); @bot = bot; @config = config; end | ||
|
||
def process(request, response) | ||
response.start(200) do |head,out| | ||
head["Content-Type"] = "text/plain" | ||
message = CGI::unescape("#{request.params['PATH_INFO'].gsub('/','')}") | ||
@bot.say(@config['irc']['channel'],"#{message}") | ||
end | ||
end | ||
end |