-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanfre_twitter_bot.rb
47 lines (38 loc) · 940 Bytes
/
sanfre_twitter_bot.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
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/ruby
require './scraper.rb'
require './twitter.rb'
require 'pry-byebug'
require 'dotenv'
require 'active_support'
require 'active_support/core_ext'
module Sanfrecce
class Bot
def initialize
Dotenv.load('.env')
@scraper = Sanfrecce::Scraper.new
@twitter = Sanfrecce::Twitter.new
end
def scrape
@scraper.scrape
end
def tweet(content)
return 'Sanfrecce.tweet There is no content' if content.blank? || @twitter.duplicated_content?(content)
@twitter.tweet(content)
content
end
def tweet_draft(content)
content
end
end
end
if __FILE__ == $0
bot = Sanfrecce::Bot.new
score_json = bot.scrape
score = Score.new(score_json[:score])
if score.active?
score.home_team = Team.new(score_json[:home])
score.away_team = Team.new(score_json[:away])
end
# puts bot.tweet(score.to_text)
puts bot.tweet_draft(score.to_text)
end