Spaces:
Build error
Build error
Update app.py
Browse files55 unmodified lines565758596061626323 unmodified lines8788899091929394959697989910010110210310410510610710899 unmodified lines20820921021121221321421521655 unmodified lineswait=wait_exponential(multiplier=1, min=4, max=10),retry=lambda e: isinstance(e, tweepy.errors.TooManyRequests))def post_tweet(api, text):return api.update_status(status=text)def main():try:23 unmodified linesdebug_print("Iniciando autenticação com Twitter...")# Autenticação com Twitter para leituraclient = tweepy.Client(bearer_token=os.getenv('TWITTER_BEARER_TOKEN'),wait_on_rate_limit=True)# Autenticação com Twitter para postagemauth = tweepy.OAuth1UserHandler(os.getenv('TWITTER_API_KEY'),os.getenv('TWITTER_API_SECRET_KEY'),os.getenv('TWITTER_ACCESS_TOKEN'),os.getenv('TWITTER_ACCESS_TOKEN_SECRET'))api = tweepy.API(auth, wait_on_rate_limit=True)# Vamos testar a autenticação com uma query simplesdebug_print("Testando autenticação...")try:99 unmodified lines# Postar tweetwith st.spinner('Postando tweet...'):debug_print("Tentando postar tweet...")post_tweet(api, generated_text)st.success("Tweet postado com sucesso!")debug_print("Tweet postado com sucesso")# Interface Streamlitst.title("Resultados da Análise")55 unmodified lines5657585960616263646566676823 unmodified lines929394959697989910010110210310410510610799 unmodified lines20720820921021121221321421521621721821955 unmodified lineswait=wait_exponential(multiplier=1, min=4, max=10),retry=lambda e: isinstance(e, tweepy.errors.TooManyRequests))def post_tweet(client, text):try:response = client.create_tweet(text=text)return responseexcept Exception as e:debug_print(f"Erro ao postar tweet: {str(e)}")raise edef main():try:23 unmodified linesdebug_print("Iniciando autenticação com Twitter...")# Autenticação com Twitter para leitura e escritaclient = tweepy.Client(bearer_token=os.getenv('TWITTER_BEARER_TOKEN'),consumer_key=os.getenv('TWITTER_API_KEY'),consumer_secret=os.getenv('TWITTER_API_SECRET_KEY'),access_token=os.getenv('TWITTER_ACCESS_TOKEN'),access_token_secret=os.getenv('TWITTER_ACCESS_TOKEN_SECRET'),wait_on_rate_limit=True)# Vamos testar a autenticação com uma query simplesdebug_print("Testando autenticação...")try:99 unmodified lines# Postar tweetwith st.spinner('Postando tweet...'):debug_print("Tentando postar tweet...")try:post_tweet(client, generated_text)st.success("Tweet postado com sucesso!")debug_print("Tweet postado com sucesso")except Exception as e:st.error(f"Erro ao postar tweet: {str(e)}")debug_print(f"Erro ao postar tweet: {str(e)}")# Interface Streamlitst.title("Resultados da Análise")
app.py+19-16