-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.rb
32 lines (29 loc) · 809 Bytes
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'rubygems'
require 'bundler'
Bundler.require
require File.join(File.dirname(__FILE__), *%w[lib robot])
require File.join(File.dirname(__FILE__), *%w[lib twitter_client])
robot = Robot.new
client = TwitterClient.new
while true do
begin
tweets = client.find_tweets_at_fwdbot
puts tweets.count
puts "------------"
puts tweets.inspect
tweets.map{|t| [t.text.downcase.split, "@#{t.from_user}", t.id]}.each do |tweet_words, from, id|
tweet_sent = false
tweet_words.each do |tw|
if (robot.respond_to?(tw))
tweet_sent = true
robot.send(tw)
client.tweet_update("Moving #{tw}", from, id)
end
end
client.tweet_failed(from, id) unless tweet_sent
end
rescue Twitter::Error => e
puts e
sleep 2
end
end