import os
import time
from crawl import crawl

import tweepy

class TwitterAPI:
    """
    Class for accessing the Twitter API.

    Requires API credentials to be available in environment
    variables. These will be set appropriately if the bot was created
    with init.sh included with the heroku-twitterbot-starter
    """
    def __init__(self):
        consumer_key = os.environ.get('TWITTER_CONSUMER_KEY')
        consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET')
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        access_token = os.environ.get('TWITTER_ACCESS_TOKEN')
        access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET')
        auth.set_access_token(access_token, access_token_secret)
        self.api = tweepy.API(auth)

    def tweet(self, message):
        """Send a tweet"""
        self.api.update_status(message)

if __name__ == "__main__":
    twitter = TwitterAPI()
    while True:
        tweet = crawl()
        if tweet:
            twitter.tweet(tweet)
        time.sleep(21600) # 6 hours

import os
import time
from crawl import crawl

import tweepy

class TwitterAPI:
    """
    Class for accessing the Twitter API.

    Requires API credentials to be available in environment
    variables. These will be set appropriately if the bot was created
    with init.sh included with the heroku-twitterbot-starter
    """
    def __init__(self):
        consumer_key = os.environ.get('TWITTER_CONSUMER_KEY')
        consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET')
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        access_token = os.environ.get('TWITTER_ACCESS_TOKEN')
        access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET')
        auth.set_access_token(access_token, access_token_secret)
        self.api = tweepy.API(auth)

    def tweet(self, message):
        """Send a tweet"""
        self.api.update_status(message)

if __name__ == "__main__":
    twitter = TwitterAPI()
    while True:
        tweet = crawl()
        if tweet:
            twitter.tweet(tweet)
        time.sleep(60) # 6 hours
        #time.sleep(21600) # 6 hours

Speed up for a while
Speed up for a while

  import os
  import time
  from crawl import crawl
  
  import tweepy
  
  class TwitterAPI:
      """
      Class for accessing the Twitter API.
  
      Requires API credentials to be available in environment
      variables. These will be set appropriately if the bot was created
      with init.sh included with the heroku-twitterbot-starter
      """
      def __init__(self):
          consumer_key = os.environ.get('TWITTER_CONSUMER_KEY')
          consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET')
          auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
          access_token = os.environ.get('TWITTER_ACCESS_TOKEN')
          access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET')
          auth.set_access_token(access_token, access_token_secret)
          self.api = tweepy.API(auth)
  
      def tweet(self, message):
          """Send a tweet"""
          self.api.update_status(message)
  
  if __name__ == "__main__":
      twitter = TwitterAPI()
      while True:
          tweet = crawl()
          if tweet:
              twitter.tweet(tweet)
+         time.sleep(60) # 6 hours
-         time.sleep(21600) # 6 hours
+         #time.sleep(21600) # 6 hours
  
Speed up for a while
## Code Before:
import os
import time
from crawl import crawl

import tweepy

class TwitterAPI:
    """
    Class for accessing the Twitter API.

    Requires API credentials to be available in environment
    variables. These will be set appropriately if the bot was created
    with init.sh included with the heroku-twitterbot-starter
    """
    def __init__(self):
        consumer_key = os.environ.get('TWITTER_CONSUMER_KEY')
        consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET')
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        access_token = os.environ.get('TWITTER_ACCESS_TOKEN')
        access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET')
        auth.set_access_token(access_token, access_token_secret)
        self.api = tweepy.API(auth)

    def tweet(self, message):
        """Send a tweet"""
        self.api.update_status(message)

if __name__ == "__main__":
    twitter = TwitterAPI()
    while True:
        tweet = crawl()
        if tweet:
            twitter.tweet(tweet)
        time.sleep(21600) # 6 hours

## Instruction:
Speed up for a while
## Code After:
import os
import time
from crawl import crawl

import tweepy

class TwitterAPI:
    """
    Class for accessing the Twitter API.

    Requires API credentials to be available in environment
    variables. These will be set appropriately if the bot was created
    with init.sh included with the heroku-twitterbot-starter
    """
    def __init__(self):
        consumer_key = os.environ.get('TWITTER_CONSUMER_KEY')
        consumer_secret = os.environ.get('TWITTER_CONSUMER_SECRET')
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        access_token = os.environ.get('TWITTER_ACCESS_TOKEN')
        access_token_secret = os.environ.get('TWITTER_ACCESS_TOKEN_SECRET')
        auth.set_access_token(access_token, access_token_secret)
        self.api = tweepy.API(auth)

    def tweet(self, message):
        """Send a tweet"""
        self.api.update_status(message)

if __name__ == "__main__":
    twitter = TwitterAPI()
    while True:
        tweet = crawl()
        if tweet:
            twitter.tweet(tweet)
        time.sleep(60) # 6 hours
        #time.sleep(21600) # 6 hours
