Skip to content

Instantly share code, notes, and snippets.

@britishtea
Last active December 18, 2015 01:39
Show Gist options
  • Save britishtea/5704900 to your computer and use it in GitHub Desktop.
Save britishtea/5704900 to your computer and use it in GitHub Desktop.
A Twitter plugin for Cinch
require "cinch"
require "tweetstream"
module Cinch
module Plugins
class Twitter
include Cinch::Plugin
def initialize(*args)
super
TweetStream.configure do |c|
c.consumer_key = config[:consumer_key]
c.consumer_secret = config[:consumer_secret]
c.oauth_token = config[:oauth_token]
c.oauth_token_secret = config[:oauth_token_secret]
c.auth_method = :oath
end
Thread.new do
TweetStream::Client.new.sample do |status|
Channel("#test").send "[#{status.user.screen_name}] #{status.text}"
end
end
end
end
end
end
bot = Cinch::Bot.new do
configure do |config|
config.server = "localhost"
config.port = 6697
config.nickname = "tweeter"
config.channels = ["#test"]
config.plugins.plugins << Cinch::Plugins::Twitter
config.plugins.options[Cinch::Plugins::Twitter] = {
:consumer_key => ""
:consumer_secret => "",
:oauth_token => "",
:oauth_token_secret => ""
}
end
end
bot.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment