Search code examples
pythontwittertweepy

replying to a tweet in tweepy


There's an issue with my code where no matter what I try, every time I reply to a tweet, it just posts as a regular status update on my timeline.

here is a snippet of the code

class StreamListener(tweepy.StreamListener):
 def on_status(self, status):
    tweetid = status.id
    tweetnouser = status.text.replace("@CarlWheezerBot", "")
    username = '@'+status.user.screen_name


    user_tweet = gTTS(text=tweetnouser, lang='en', slow=False)

    # Saving the converted audio

    user_tweet.save("useraudio/text2speech.mp3")

    # importing the audio and getting the audio all mashed up
    text2speech = AudioFileClip("useraudio/text2speech.mp3")
    videoclip = VideoFileClip("original_video/original_cut.mp4")
    editedAudio = videoclip.audio

    # splicing the original audio with the text2speech
    compiledAudio = CompositeAudioClip([editedAudio.set_duration(3.8), text2speech.set_start(3.8)])
    videoclip.audio = compiledAudio

    # saving the completed video fie
    videoclip.write_videofile("user_video/edited.mp4", audio_codec='aac')

    upload_result = api.media_upload("user_video/edited.mp4")
    api.update_status( status='@CarlWheezerBot',in_reply_to_status_id=[tweetid], media_ids=[upload_result.media_id_string], auto_populate_reply_metadata=True)

I have also tried it without any status, as well as using status.id_str. Nothing seems to work., I have done it without the metadata parameter as well. I am following the documentation word for word.


Solution

  • OKAY. for everyone reading this in the future

    use this in_reply_to_status_id=tweetid

    do not use the square brackets. Everything works perfectly now