Class: TwitterTopicBot

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_topic_bot.rb,
lib/twitter_topic_bot/version.rb,
lib/twitter_topic_bot/api_client.rb,
lib/twitter_topic_bot/tweet_filterer.rb

Defined Under Namespace

Classes: ApiClient, TweetFilterer

Constant Summary collapse

VERSION =
'0.2.0'

Instance Method Summary collapse

Constructor Details

#initialize(content_preparer, credentials) ⇒ TwitterTopicBot

Returns a new instance of TwitterTopicBot.



7
8
9
10
# File 'lib/twitter_topic_bot.rb', line 7

def initialize(content_preparer, credentials)
  @content_preparer = content_preparer
  @api_client = TwitterTopicBot::ApiClient.new(credentials)
end

Instance Method Details

#follow_followersObject



44
45
46
47
# File 'lib/twitter_topic_bot.rb', line 44

def follow_followers
  # TODO: it is too easy to hit the rate limit on this one
  api_client.follow *api_client.followers
end

#follow_someoneObject



22
23
24
# File 'lib/twitter_topic_bot.rb', line 22

def follow_someone
  api_client.follow(user_to_follow)
end

#reply_to_someoneObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/twitter_topic_bot.rb', line 31

def reply_to_someone
  tweet = tweet_to_reply_to
  reply = content_preparer.prepare_reply(
            tweet.text,
            tweet.user.screen_name
          )

  api_client.tweet(
    reply,
    in_reply_to_status_id: tweet.id
  )
end

#retweet_mentionsObject



26
27
28
29
# File 'lib/twitter_topic_bot.rb', line 26

def retweet_mentions
  # TODO: filter out already retweeted mentions
  api_client.retweet *api_client.mentions
end

#retweet_someoneObject



18
19
20
# File 'lib/twitter_topic_bot.rb', line 18

def retweet_someone
  api_client.retweet(tweet_to_retweet)
end

#tweetObject



12
13
14
15
16
# File 'lib/twitter_topic_bot.rb', line 12

def tweet
  api_client.tweet(
    content_preparer.prepare_tweet
  )
end