Skip to content

Instantly share code, notes, and snippets.

@donpdonp
Created October 3, 2011 20:32
Show Gist options
  • Save donpdonp/1260156 to your computer and use it in GitHub Desktop.
Save donpdonp/1260156 to your computer and use it in GitHub Desktop.
twitter stream to irc
require 'tweetstream'
require 'json'
require 'irc-socket'
SETTINGS = JSON.load(File.open("settings.json"))
@irc = IRCSocket.new(SETTINGS["server"])
@irc.connect
@irc.nick SETTINGS["nick"]
@irc.user SETTINGS["nick"], 0, "*", "Neuron Bot"
@irc.join("#pdxtwitter")
puts "connecting to irc"
TweetStream.configure do |config|
config.consumer_key = 'key'
config.consumer_secret = 'secret'
config.oauth_token = 'token'
config.oauth_token_secret = 'token-secret'
config.auth_method = :oauth
# config.parser = :yajl
config.parser = :json_gem
end
client = TweetStream::Client.new
client.on_error do |message|
puts message
end
client.on_direct_message do |direct_message|
puts direct_message.text
end
client.on_timeline_status do |status|
@irc.privmsg("#pdxtwitter", "#{status.user.screen_name}: #{status.text}")
end
client.userstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment