Created
December 31, 2011 19:18
-
-
Save ainame/1545069 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
| # -*- 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