Class: TwitterTopicBot

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

Defined Under Namespace

Modules: Schedulable Classes: ApiClient, TweetFilterer

Constant Summary collapse

VERSION =
'0.3.1'

Instance Method Summary collapse

Methods included from Schedulable

#schedule

Constructor Details

#initialize(content_preparer, credentials) ⇒ TwitterTopicBot

Returns a new instance of TwitterTopicBot.



9
10
11
12
# File 'lib/twitter_topic_bot.rb', line 9

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

Instance Method Details

#follow_followersObject



46
47
48
49
# File 'lib/twitter_topic_bot.rb', line 46

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



24
25
26
# File 'lib/twitter_topic_bot.rb', line 24

def follow_someone
  api_client.follow(user_to_follow)
end

#reply_to_someoneObject



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

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



28
29
30
31
# File 'lib/twitter_topic_bot.rb', line 28

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

#retweet_someoneObject



20
21
22
# File 'lib/twitter_topic_bot.rb', line 20

def retweet_someone
  api_client.retweet(tweet_to_retweet)
end

#tweetObject



14
15
16
17
18
# File 'lib/twitter_topic_bot.rb', line 14

def tweet
  api_client.tweet(
    content_preparer.prepare_tweet
  )
end