Created
November 17, 2009 00:19
-
-
Save takkanm/236461 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
#!/usr/bin/env ruby | |
# coding: utf-8 | |
require 'rubygems' | |
require 'httparty' | |
require 'pit' | |
require 'optparse' | |
class Twitter | |
include HTTParty | |
base_uri 'twitter.com' | |
config = Pit.get("balse", :require => { | |
"user_id" => "required id", | |
"password" => "required password" | |
}) | |
basic_auth *config.values_at("user_id", "password") | |
format :xml | |
def initialize(allow_list) | |
@allow_list = allow_list | |
@message_id = nil | |
end | |
def balse? | |
query = @message_id ? ({:since_id => @message_id}) : ({}) | |
res = Twitter.get('/statuses/mentions.xml', :query => query) | |
mentions = res["statuses"] if res.key? "statuses" | |
@message_id = mentions[0]["id"] if mentions and not mentions.empty? | |
mentions && mentions.any? do |mention| | |
@allow_list.include?(mention["user"]["screen_name"]) && mention["text"] =~ /バルス/ | |
end | |
end | |
end | |
def action() | |
puts "目が、目がぁぁぁぁ" | |
end | |
t = Twitter.new %w(ngtyk) | |
loop do | |
action if t.balse? | |
sleep 10 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment