Created
July 18, 2012 12:22
-
-
Save hanachin/3135888 to your computer and use it in GitHub Desktop.
ふぁぼしゃわー
This file contains 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
consumer_key: your_consumer_key_here | |
consumer_secret: your_consumer_secret_here | |
users: | |
- screen_name: favshower | |
oauth_token: your_oauth_token | |
oauth_token_secret: your_oauth_token_secret_here | |
- screen_name: favshower1 | |
oauth_token: your_oauth_token | |
oauth_token_secret: your_oauth_token_secret_here |
This file contains 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 'yaml' | |
require 'twitter' | |
require 'parallel' | |
require 'pp' | |
class Favshower | |
attr_accessor :config, :users | |
def initialize | |
@config = YAML.load_file('config.yml') | |
@users = @config["users"].map {|u| | |
Twitter::Client.new({ | |
consumer_key: @config["consumer_key"], | |
consumer_secret: @config["consumer_secret"], | |
oauth_token: u["oauth_token"], | |
oauth_token_secret: u["oauth_token_secret"], | |
}) | |
} | |
end | |
def bom(screen_name, count = 10) | |
statuses = @users.first.user_timeline(screen_name, count: 200)[0...count] | |
Parallel.each_with_index(statuses, in_processes: @users.size) do |s, i| | |
begin | |
@users[i % @users.size].favorite(s.id) | |
@users[i % @users.size].unfavorite(s.id) | |
puts "#{s.text}をふぁぼってあんふぁぼしました。" | |
rescue | |
puts "#{s.text}をふぁぼるのに失敗しました。" | |
end | |
end | |
end | |
def unfav(status_id) | |
count = Parallel.map((0...@users.size).to_a) do |i| | |
begin | |
@users[i % @users.size].unfavorite(status_id) | |
1 | |
rescue | |
0 | |
end | |
end.inject(&:+) | |
puts "#{count}回、#{status_id}をふぁぼりました。" | |
end | |
def fav(status_id) | |
count = Parallel.map((0...@users.size).to_a) do |i| | |
begin | |
@users[i % @users.size].favorite(status_id) | |
1 | |
rescue | |
0 | |
end | |
end.inject(&:+) | |
puts "#{count}回、#{status_id}をふぁぼりました。" | |
end | |
def kill_ngskbot | |
@users.each {|u| | |
u.update("@ngskbot " * 9) | |
} | |
end | |
def limit | |
pp @users.map(&:rate_limit_status).map {|r| | |
[r.reset_time, r.remaining_hits] | |
} | |
end | |
end | |
screen_name = ARGV[0] | |
count = (ARGV[1] || 50).to_i | |
exit unless screen_name | |
puts "#{count}のふぁぼを、#{screen_name}に。" | |
Favshower.new.bom(screen_name, count) | |
# Favshower.new.limit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment