def main(): api = create_api() f = Follow(api) while True: f.follow_followers() logger.info('Waiting...') time.sleep(60)
def busquedaEnWeb(palabra): d = Def("", 1) api = create_api() # Web scrapping url = "https://dle.rae.es/" + palabra pagina = requests.get(url) soup = BeautifulSoup(pagina.content, 'html.parser') results = soup.find("meta", attrs={"name": 'twitter:description'}) results = str(results) x = er_definicion.search(results) # Desde el 1 hasta -1 para eliminar las comillas respectivas d.definicion = x.group(1)[1:-1] if d.definicion.startswith("Definici"): d.definicion = d.definicion[d.definicion.find("1"):] # Se comprueba la longitud del tuit if len(d.definicion) > 263: d.definicion = d.definicion[:-3] + "..." d.error = 0 if d.definicion.startswith("Versión electrónica "): # Se mira en el diccionario de Easter Eggs. if palabra in diccionario.keys(): d.definicion = diccionario.get(palabra) d.error = 0 # Si no se encuentra en el diccionario de easter eggs. else: d.definicion = "Error, la palabra no existe o no está añadida actualmente en el diccionario." d.error = 1 return d
def main(): api = create_api() since_id = 1 while True: since_id = check_replies(api, since_id) logger.info("Waiting...") time.sleep(60)
def main(): # Generamos el objeto para interactuar con Twitter. # create_api() está definido en el archivo config.py api = create_api() # Cargamos el último tweet respondido desde la descripción del usuario # (esto es un hack súper grasa, pero Heroku no tiene persistencia # de datos, y son las 2 AM). try: since_id = int(api.me().description) except Exception: since_id = 1 last_saved_since_id = since_id # Loop infinito. while True: # Buscamos menciones. since_id = check_mentions(api, since_id) # Guardamos el último tweet respondido como descripción del usuario if last_saved_since_id != since_id: try: api.update_profile(description=since_id) last_saved_since_id = since_id except Exception: logger.exception("Error al guardar la descripción.") # Esperamos 30 segundos logger.info("Esperando 30 segundos.") time.sleep(30)
def main(): api = create_api() since_id = max([i.id for i in api.mentions_timeline()]) while True: since_id = check_mentions(api, since_id) logger.info("Waiting...") time.sleep(5)
def send_tweet(): ''' Uses tweet data generated by the prepare_tweet_data() function to send a tweet ''' # Retrieves data for the tweet image_name, image_path, status_text, tweeted_images_file_path = tweet_data.prepare_tweet_data( ) if image_path != '': # Creates API connection api = create_api() success = 0 tweet_id_before = get_latest_tweet_id(api) # If the tweet was made without error, uses the id of the latest tweet to check whether the attempt really was successful, # updates the success variable, and returns the variable try: # Runs Tweepy command api.update_with_media(image_path, status=status_text) # Appends the name of the uploaded image to tweeted_images.txt save_data(tweeted_images_file_path, [image_name]) except (Exception, TweepError) as e: print(e) sleep(60 * 2) tweet_id_after = get_latest_tweet_id(api) if tweet_id_after and tweet_id_before != tweet_id_after: print(f'Uploaded {image_name}...') success = 1 return success
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, [response_words_one, response_words_two, response_words_three], since_id) logger.info("Waiting...") time.sleep(60)
def index(): logger.info("Bienvenido a @contusimpuestos BOT") global update_id global link # Init APIs de Telegram y Twitter api,telegramBot = create_api() # Loop del bot while True: # Chequear si hay links disponibles para twitear try: link = getLink(telegramBot) except NetworkError: sleep(1) except Unauthorized: update_id += 1 # Si hay link... if(link != None): # Lo twiteamos! tweet_link(api,link) link = None # Espero un poco antes de volver a chequear #logger.info("keep waiting..") time.sleep(sleep_time_sec) return 0
def main(): api = create_api() since_id = 1262491407455002632 while True: since_id = check_mentions(api, since_id) logger.info('Waiting...') time.sleep(60)
def main(): api = create_api() since_id = 1258698161281019910 while True: since_id = check_mentions(api, since_id) logger.info("Waiting...") time.sleep(60)
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, ["#ZTM", "#Zerotomastery"], since_id) fav_retweet() time.sleep(60)
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, ['help', 'support'], since_id) logger.info('Waiting...') time.sleep(60)
def main(): api = create_api() interval = 60 * 60 * 24 # tweet once a day while True: tweet_verse(api) logger.info("Waiting...") time.sleep(interval) # in seconds
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, ["help", "support"], since_id) logger.info("Waiting...") time.sleep(60)
def main(): api = create_api() while True: follow_followers(api) logger.info("Waiting...") time.sleep(60)
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, ["@JSaBOTina"], since_id) logger.info("Waiting...") time.sleep(3600)
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, ["#remind", "#feedback"], since_id) logger.info("Waiting...") sleep(60)
def main(): # make_first_tweet() db_connection = open_database(dbname, username, password, endpoint, port) cursor = set_cursor(db_connection) api = create_api() since_id = 1 players = get_players_from_db(cursor, db_connection) cursor.close() db_connection.close() # reset tracking status for all players for all subscribers update_tracking_status(None, None, False) # start processes. Each process will use its own cursor and db connection. # start process to monitor mentions mentions_process = multiprocessing.Process(target=check_mentions, args=( api, players, since_id, )) mentions_process.start() # start another process to go through all subscribers check_subscriber_process = multiprocessing.Process(target=start_tracking, args=(api, )) check_subscriber_process.start() # start another process to update fixture schedule once every week. Make sure to not update during games. # Use scheule library not sched. Update every Tuesday update_schedules_process = multiprocessing.Process(target=update_schedules) update_schedules_process.start()
def main(keywords): api = create_api() tweets_listener = FavRetweetListener(api) print("sleep") stream = tweepy.Stream(api.auth, tweets_listener) stream.filter(track=keywords, languages=["en"])
def main(): api = create_api() date_since = "2020-10-10" while True: follow_followers(api, date_since) logger.info("Waiting...") time.sleep(120)
def main(): api = create_api() since_id = 1 while True: since_id = favorite_retweet_tweets(api, ['python', 'django'], since_id) logger.info('Waiting...') time.sleep(60)
def main(): api = create_api() # since_id = 1 while True: check_mentions(api) logger.info("Waiting...") time.sleep(15)
def main(): api = create_api() while True: text = interactive_conditional_samples.interact_model( text="Todo empezo. /n", length=200).split("<|endoftext|>")[0][:279].split("\n\n\n")[0] send_tweet(api=api, message=text) time.sleep(3600)
def main(): api = create_api() since_id = 1 while True: since_id = check_mentions(api, ["cat", "please", "kitty", "kat"], since_id) logger.info("Waiting...") ##wait 1 minute before checking mentions again time.sleep(60)
def main(): api = create_api() since_id = 1206662450784944136 while True: print(since_id) since_id = Mention(api, since_id) logger.info("Waiting...") time.sleep(60)
def main(): """ Driver method """ api = create_api() tweet_listener = HutsbotStreamListener(api) stream = tweepy.Stream(api.auth, tweet_listener) stream.filter(track=["hutspot"])
def main(): api = create_api() since_id = 1 while True: print(since_id) since_id = chek_mentions(api, ["help", "support", "development", "lessons"], since_id) logger.info("Waiting..") time.sleep(60)
def main(): api = create_api() tweets = api.favorites() for tweet in tweets: print(f"unliking and unretweeting tweet {tweet.id}") api.destroy_favorite(tweet.id) api.unretweet(tweet.id)
def main(): api = create_api() since_id = 1 while True: print(since_id) since_id = check_mentions(api, ["factsheet", "fact sheet"], since_id) logger.info("Waiting...") time.sleep(60)
def main(): api = create_api() running = True; while (running): followBack(api) logger.info("Waiting...") #time.sleep(60) running = False;