Skip to content

Instantly share code, notes, and snippets.

@takkanm
Created November 17, 2009 00:19
Show Gist options
  • Save takkanm/236461 to your computer and use it in GitHub Desktop.
Save takkanm/236461 to your computer and use it in GitHub Desktop.
#!/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