whats wrong in this code?

carluhs

Newbie
Joined
Jul 3, 2022
Messages
24
Reaction score
4
Hi, i have no idea about coding so i asked for help to chat gpt, i wanted to make a script for auto post in X but its not working althought when i run it in python doesnt say any error.
import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler

# Configurar las claves de acceso
consumer_key = '??????????????????'
consumer_secret = '??????????????????'
access_token = '??????????????????'
access_token_secret = '????????????????'

# Autenticar con la API de Twitter
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

# Definir la función para responder a los tweets
def responder_tweet(tweet_id, username):
mensaje_personalizado = "whars up?"
imagen = "C:\\Users\\croru\\OneDrive\\Imágenes\\bot\\bot.png" # Ruta de la imagen que deseas enviar como respuesta

# Responder al tweet con el mensaje personalizado y la misma foto cada vez
api.update_with_media(filename=imagen, status=mensaje_personalizado, in_reply_to_status_id=tweet_id)

# Configurar un listener para monitorear tweets
class MyStreamListener(StreamListener):
def init(self, usuarios_a_monitorear):
super(MyStreamListener, self).init()
self.usuarios_a_monitorear = usuarios_a_monitorear

def on_status(self, status):
# Obtener el ID del tweet y el nombre de usuario del autor
tweet_id = status.id
username = status.user.screen_name

# Verificar si el tweet es de uno de los usuarios específicos que deseas monitorear
if username in self.usuarios_a_monitorear:
# Responder al tweet
responder_tweet(tweet_id, username)

# Lista de usuarios a los que deseas responder
usuarios_a_monitorear = ['carluuhs']

# Iniciar el stream y monitorear tweets en tiempo real
my_stream_listener = MyStreamListener(usuarios_a_monitorear)
my_stream = tweepy.Stream(auth=api.auth, listener=my_stream_listener)

# Iniciar el stream para monitorear los usuarios específicos
my_stream.filter(follow=usuarios_a_monitorear)
 
Before moving into this, be aware that X API has become extremely expensive, when you run the py script it doesnt return anyhting?
Ask GPT to add some logging there because you need to know if such variables are being rightly set.
 
Better hire a freelancer or search for source codes, coding with ChatGPT is possible but only for little Things in my opinion.

If you dont understand coding its hard because you dont really know what you are doing.
 
Before moving into this, be aware that X API has become extremely expensive, when you run the py script it doesnt return anyhting?
Ask GPT to add some logging there because you need to know if such variables are being rightly set.
hum, yeah you are right but there is a free plan with 1k tweets for free. for me that amount its enough. in the beginning i was seeing some errors in py but i handle it to fix it, the problem was the tweepy version, now doesnt show any error but doesnt work either so idk
Better hire a freelancer or search for source codes, coding with ChatGPT is possible but only for little Things in my opinion.

If you dont understand coding its hard because you dont really know what you are doing.
its better when people does things for you but that means money and i want invest the money i win from internet so far, hire someone is expensive in the beginning. i made some other scripts for games but the difference was i had a script made by a friend that was for the game we were sharing, i just used it as a template and worked
 
Hi, i have no idea about coding so i asked for help to chat gpt, i wanted to make a script for auto post in X but its not working althought when i run it in python doesnt say any error.
import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler

# Configurar las claves de acceso
consumer_key = '??????????????????'
consumer_secret = '??????????????????'
access_token = '??????????????????'
access_token_secret = '????????????????'

# Autenticar con la API de Twitter
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

# Definir la función para responder a los tweets
def responder_tweet(tweet_id, username):
mensaje_personalizado = "whars up?"
imagen = "C:\\Users\\croru\\OneDrive\\Imágenes\\bot\\bot.png" # Ruta de la imagen que deseas enviar como respuesta

# Responder al tweet con el mensaje personalizado y la misma foto cada vez
api.update_with_media(filename=imagen, status=mensaje_personalizado, in_reply_to_status_id=tweet_id)

# Configurar un listener para monitorear tweets
class MyStreamListener(StreamListener):
def init(self, usuarios_a_monitorear):
super(MyStreamListener, self).init()
self.usuarios_a_monitorear = usuarios_a_monitorear

def on_status(self, status):
# Obtener el ID del tweet y el nombre de usuario del autor
tweet_id = status.id
username = status.user.screen_name

# Verificar si el tweet es de uno de los usuarios específicos que deseas monitorear
if username in self.usuarios_a_monitorear:
# Responder al tweet
responder_tweet(tweet_id, username)

# Lista de usuarios a los que deseas responder
usuarios_a_monitorear = ['carluuhs']

# Iniciar el stream y monitorear tweets en tiempo real
my_stream_listener = MyStreamListener(usuarios_a_monitorear)
my_stream = tweepy.Stream(auth=api.auth, listener=my_stream_listener)

# Iniciar el stream para monitorear los usuarios específicos
my_stream.filter(follow=usuarios_a_monitorear)
It seems like you're trying to create a Python script for auto-responding to tweets using Tweepy. I can see some indentation issues in your code, which can cause problems when running it.
 
Hi, i have no idea about coding so i asked for help to chat gpt, i wanted to make a script for auto post in X but its not working althought when i run it in python doesnt say any error.
import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler

# Configurar las claves de acceso
consumer_key = '??????????????????'
consumer_secret = '??????????????????'
access_token = '??????????????????'
access_token_secret = '????????????????'

# Autenticar con la API de Twitter
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

# Definir la función para responder a los tweets
def responder_tweet(tweet_id, username):
mensaje_personalizado = "whars up?"
imagen = "C:\\Users\\croru\\OneDrive\\Imágenes\\bot\\bot.png" # Ruta de la imagen que deseas enviar como respuesta

# Responder al tweet con el mensaje personalizado y la misma foto cada vez
api.update_with_media(filename=imagen, status=mensaje_personalizado, in_reply_to_status_id=tweet_id)

# Configurar un listener para monitorear tweets
class MyStreamListener(StreamListener):
def init(self, usuarios_a_monitorear):
super(MyStreamListener, self).init()
self.usuarios_a_monitorear = usuarios_a_monitorear

def on_status(self, status):
# Obtener el ID del tweet y el nombre de usuario del autor
tweet_id = status.id
username = status.user.screen_name

# Verificar si el tweet es de uno de los usuarios específicos que deseas monitorear
if username in self.usuarios_a_monitorear:
# Responder al tweet
responder_tweet(tweet_id, username)

# Lista de usuarios a los que deseas responder
usuarios_a_monitorear = ['carluuhs']

# Iniciar el stream y monitorear tweets en tiempo real
my_stream_listener = MyStreamListener(usuarios_a_monitorear)
my_stream = tweepy.Stream(auth=api.auth, listener=my_stream_listener)

# Iniciar el stream para monitorear los usuarios específicos
my_stream.filter(follow=usuarios_a_monitorear)
It appears that the indentation in your Python code is incorrect. Python relies on proper indentation to define code blocks, so it's essential to maintain consistent indentation levels.
 
Back
Top