Ejemplo n.º 1
0
 def run(self):
     query_keywords = list()
     for item in config.news_keywords:
         query_keywords = query_keywords + list(config.news_keywords[item])
     query_keywords = query_keywords + config.boost_keywords
     while True:
         try:
             query = random.choice(query_keywords)
             for item in api.search(q='#' + query,
                                    count=50,
                                    lang='en',
                                    result_type='mixed'):
                 if not item.user.following and not item.favorited:
                     try:
                         api.create_favorite(item.id)
                         api.create_friendship(item.user.screen_name)
                         debug.alert('Followed a similar twitter!')
                     except tweepy.TweepError as ex:
                         debug.error(
                             'Unknown error occured in the search loop!',
                             ex)
                 time.sleep(30)
         except tweepy.TweepError as ex:
             debug.error('Error occured in the search loop!', ex)
         finally:
             time.sleep(60 * 15)
Ejemplo n.º 2
0
def autoremote_notify(message, device, debug_alert=''):
    import private
    print('Notifying AutoRemote with ', message)
    try:
        requests.get(autoremote_url + message + '&deviceId=' + private.autoremote_device[device] + '&apikey=' + private.autoremote_key)
    except:
        print('AutoRemote Connection Failed')
        if debug_alert != '':
            alert('AR ' + debug_alert)
    return
Ejemplo n.º 3
0
def unfollow_loop():
    try:
        followers = api.followers_ids(me.screen_name)
        friends = api.friends_ids(me.screen_name)
        for friend in friends:
            if friend not in followers:
                api.destroy_friendship(friend)
                debug.alert('Unfollowed an unsupporting friend!')
                time.sleep(30)
    except tweepy.TweepError as ex:
        debug.error('Error occured in the unfollow loop!', ex)
Ejemplo n.º 4
0
 def run(self):
     while True:
         try:
             if 'boost_tweet' in locals(): api.destroy_status(boost_tweet.id)
             boost_tweet = api.update_status('Support our Twitter! #' + ' #'.join(config.boost_keywords))
             debug.alert('Re-posted boost tweet.')
         except tweepy.TweepError as ex:
             debug.error('Error occured in the boost loop', ex)
         finally:
             random.shuffle(config.boost_keywords)
             time.sleep(60*5)
Ejemplo n.º 5
0
 def loop_boost(self):
     while True:
         try:
             if 'boost_tweet' in locals():
                 self.api.destroy_status(boost_tweet.id)
             boost_tweet = self.api.update_status(
                 'RT for followers! #' + ' #'.join(config.boost_keywords))
             self.tweets += 1
             debug.alert('Re-posted boost tweet.')
         except tweepy.TweepError as ex:
             debug.error('Error occured in the boost loop', ex)
         finally:
             random.shuffle(config.boost_keywords)
             time.sleep(60 * 5)
Ejemplo n.º 6
0
 def run(self):
     while True:
         try:
             for tweet in tweepy.Cursor(api.home_timeline, exclude_replies=True).items(50):
                 if tweet.user.screen_name != me.screen_name:
                     if not tweet.favorited:
                         if random.choice([True, False, False, False, False]):
                             api.create_favorite(tweet.id)
                             debug.alert('Favorited a friends tweet!')
                 time.sleep(30)
         except tweepy.TweepError as ex:
             debug.error('Error occured in the favorite loop!', ex)
         finally:
             time.sleep(60*15)
Ejemplo n.º 7
0
 def run(self):
     while True:
         try:
             followers = api.followers_ids(me.screen_name)
             friends   = api.friends_ids(me.screen_name)
             if me.friends_count / me.followers_count == 3:
                 debug.action('Following to follower ratio is off! Starting the unfollow loop...')
                 unfollow_loop()
             for follower in followers:
                 if not follower in friends:
                     api.create_friendship(follower)
                     api.send_direct_message(screen_name=follower, text='Thanks for following our Twitter. Be sure to share us with your friends & keep up with the latest sports news!')
                     debug.alert('Followed back a follower!')
                 time.sleep(30)
         except tweepy.TweepError as ex:
             debug.error('Error occured in the follow loop!', ex)
         finally:
             time.sleep(60*15)
Ejemplo n.º 8
0
 def run(self):
     while True:
         try:
             news   = functions.get_news()
             tweets = list()
             for item in tweepy.Cursor(api.user_timeline, exclude_replies=True).items(50):
                 tweets.append(item.text.split('... ')[0])
                 time.sleep(2)
             for item in news:
                 split = item.split('... ')[0]
                 if split not in tweets:
                     api.update_status(item)
                     debug.alert('A tweet has been posted.')
                 time.sleep(60*5)
         except tweepy.TweepError as ex:
             debug.error('Error occured in the news loop', ex)
         finally:
             time.sleep(60*15)
Ejemplo n.º 9
0
def eventghost_notify(message, *payload, debug_alert=''):
    print('Notifying EventGhost with ', message, ' ', payload)
    # Check to see that EventGhost is running, open it if not
    tmp = os.popen("tasklist").read()
    if "EventGhost.exe" not in tmp and "eventghost.exe" not in tmp:
        print('EventGhost not running. Starting...')
        subprocess.run([eventghost_location], shell=True)
        time.sleep(30)
    # Create EventGhost notification
    try:
        subprocess.run([eventghost_location, '-e', message + ' ', *payload], shell=True, timeout=90)
    # Restart EventGhost if it's frozen
    except subprocess.TimeoutExpired:
        if eventghost_restart() == 'OK':
            eventghost_notify(message, *payload, debug_alert)
        if debug_alert != '':
            alert('EG ' + debug_alert)
        eventghost_notify(message, *payload, debug_alert)
    return
Ejemplo n.º 10
0
 def loop_unfollow(self):
     try:
         followers = self.api.followers_ids(self.me.screen_name)
         friends = self.api.friends_ids(self.me.screen_name)
         non_friends = [
             friend for friend in friends if friend not in followers
         ]
         non_friends.reverse()
         debug.action('Unfollowing {0} unsupporting friends...'.format(
             len(non_friends)))
         for friend in non_friends:
             self.api.destroy_friendship(friend)
             self.unfollows += 1
             debug.alert('Unfollowed an unsupporting friend!')
             if self.unfollows == self.max_unfollows:
                 break
             else:
                 time.sleep(60 * functions.random_int(10, 15))
     except tweepy.TweepError as ex:
         debug.error('Error occured in the unfollow loop!', ex)
     finally:
         self.unfollows = 0
Ejemplo n.º 11
0
 def loop_follow(self):
     while True:
         try:
             followers = api.followers_ids(me.screen_name)
             friends = api.friends_ids(me.screen_name)
             non_friends = [
                 friend for friend in followers if friend not in friends
             ]
             debug.action('Following back {0} supporters...'.format(
                 len(non_friends)))
             for follower in non_friends:
                 api.create_friendship(follower)
                 self.follows += 1
                 debug.alert('Followed back a follower!')
                 if self.follows >= self.max_follows:
                     break
                 if self.send_message:
                     api.send_direct_message(screen_name=follower,
                                             text=self.message)
                 time.sleep(30)
         except tweepy.TweepError as ex:
             debug.error('Error occured in the follow loop!', ex)
         finally:
             time.sleep(60 * 15)
Ejemplo n.º 12
0
 def loop_search(self):
     while True:
         try:
             query = random.choice(config.boost_keywords)
             for item in api.search(q='#' + query,
                                    count=50,
                                    lang='en',
                                    result_type='recent'):
                 if not item.user.following and not item.favorited:
                     try:
                         api.create_favorite(item.id)
                         api.create_friendship(item.user.screen_name)
                         self.favorites += 1
                         self.follows += 1
                         debug.alert('Followed a booster twitter!')
                     except tweepy.TweepError as ex:
                         debug.error(
                             'Unknown error occured in the search loop!',
                             ex)
                 time.sleep(30)
         except tweepy.TweepError as ex:
             debug.error('Error occured in the search loop!', ex)
         finally:
             time.sleep(60 * 15)