Changeset - d8371901f34c
[Not reviewed]
default
0 1 0
Dennis Fink - 8 years ago 2017-02-13 16:28:20
dennis.fink@c3l.lu
Added new tweets and added lat and lon to tweets
1 file changed with 8 insertions and 3 deletions:
0 comments (0 inline, 0 general)
spaceapi/utils.py
Show inline comments
 
@@ -29,10 +29,12 @@ possible_closed_tweets = (
 
    'The space is now closed!',
 
    'We\'re closed now! See you soon.',
 
    'Sorry, we are closed now!',
 
    'The ChaosStuff is now closed! Come back another time!',
 
    'Poweroff process finished! We\'re closed!',
 
)
 

	
 

	
 
def post_tweet(tweet):
 
def post_tweet(tweet, spaceapi=None):
 
    if 'TWITTER_CONSUMER_KEY' in current_app.config:
 
        auth = tweepy.OAuthHandler(
 
            current_app.config['TWITTER_CONSUMER_KEY'],
 
@@ -43,7 +45,10 @@ def post_tweet(tweet):
 
            current_app.config['TWITTER_ACCESS_TOKEN_SECRET']
 
        )
 
        api = tweepy.API(auth)
 
        api.update_status(tweet)
 
        if spaceapi is None:
 
            api.update_status(tweet)
 
        else:
 
            api.update_status(tweet, lat=spaceapi['location']['lat'], lon=spaceapi['location']['lon'])
 

	
 

	
 
class Singleton:
 
@@ -132,7 +137,7 @@ class ActiveStatus(Singleton, dict):
 
    def send_tweet(self, value):
 
        tweet = random.choice(possible_open_tweets) if value else random.choice(possible_closed_tweets)
 
        try:
 
            post_tweet(tweet)
 
            post_tweet(tweet, self)
 
        except Exception as e:
 
            current_app.logger.error('Sending tweet failed! %s' % e,
 
                                     exc_info=True)
0 comments (0 inline, 0 general)