-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonopolybot.rb
37 lines (29 loc) · 1.1 KB
/
monopolybot.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
33
34
35
36
37
require File.join(File.dirname(__FILE__), "twitterbot")
module Monopolybot
CARDS = File.join(File.dirname(__FILE__), 'lib', 'fixtures', 'chance_cards.yml')
def self.last_id
Twitter::Search.new.from(configatron.monopolybot_twittername).per_page(1).fetch["max_id"]
end
def self.db_setup
DataMapper.setup(:default, "#{configatron.db_adapter}://#{configatron.db_username}:#{configatron.db_password}@#{configatron.db_server}/#{configatron.db_name}")
end
def self.runner
self.db_setup
loop do
Twitter::Search.new("monopoly").since(self.last_id).each do |new_request|
self.send_response(new_request)
end
sleep 8
end
end
def self.send_response(request)
puts "@#{request["from_user"]} #{self.response(request)}"
responder = Twitter::Base.new(configatron.monopolybot_twittername, configatron.monopolybot_password)
responder.update("@#{request["from_user"]} #{self.response(request)}")
responder.follow(request["from_user"])
end
def self.response(request)
return MonopolybotResponse.new(request["text"])
end
end
#Winebot.runner