Skip to content

Instantly share code, notes, and snippets.

@ainame
Created December 31, 2011 19:18
Show Gist options
  • Select an option

  • Save ainame/1545069 to your computer and use it in GitHub Desktop.

Select an option

Save ainame/1545069 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
#
# 自分のbot
require 'active_support'
require 'twitter'
require 'json'
# モジュール名未定
module Chofu
module Twitter
def self.activate
@config = JSON.parse(open("settings.json").read)
Object::Twitter.configure do |config|
config.consumer_key = @config["consumer_key"]
config.consumer_secret = @config["consumer_secret"]
config.oauth_token = @config["oauth_token"]
config.oauth_token_secret = @config["oauth_token_secret"]
end
end
def self.twitter
if @twitter
return @twitter
else
self.activate
return @twitter = Object::Twitter::Client.new
end
end
def self.update(text)
self.twitter.update(text)
end
end
end
words = %w{腹減った 眠い 肉食いたい 二郎食いたい 暑い Rubyたのしい}
Chofu::Twitter.update(words.sample)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment