Created
October 3, 2011 20:32
-
-
Save donpdonp/1260156 to your computer and use it in GitHub Desktop.
twitter stream to irc
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
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