Created
August 18, 2016 04:35
-
-
Save elmobp/31ab06cb287c1ae684338446079b5966 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
coffee scirpt | |
module.exports = (robot) -> | |
robot.respond /agile\s+(.+)/i, (msg) -> | |
input = msg.match[1] | |
cp = require "child_process" | |
encoded = new Buffer(input).toString('base64') | |
cp.exec "bundle exec ruby scripts/ruby/agile.rb #{encoded}", (error, stdout, stderr) -> | |
if error | |
msg.send "Error: #{error.code} - #{stderr}" | |
else | |
msg.send stdout | |
ruby script | |
#!/usr/bin/env ruby | |
require 'rss' | |
require 'open-uri' | |
url = 'https://twitrss.me/twitter_user_to_rss/?user=agiledrinking' | |
open(url) do |rss| | |
feed = RSS::Parser.parse(rss) | |
data = feed.items | |
out = data[rand(data.size)] | |
puts out.description.gsub(/<\/?[^>]*>/, "") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment