Skip to content
Advertisement

I made a Twitter bot that automatically tweets Direct Messages:

I recently started to learn python, i had 0 knowledge on pyhton, and in the last few weeks i’ve been studying python and the twitter api.

I decided to work on a simple twitter bot, that automatically posts whatever people send on my direct messages, and i maneged to do so.

Here’s my code:

JavaScript

The code works, but not 100%, i’m able to extract the text from the Dm and use it on the api.update_status("/bot: " + text) but when it loops i get the following error:

JavaScript

i’ve looked it up, and tried many things, for example:

JavaScript

All i want is a way to keep the code going and ignore messages and tweets that were already sent, also wait for new dm’s

Another thing that kept happening was that when i tried testing the extraction of the text, i kept getting the same text from the same dm, instead of getting a nother newer one.

Advertisement

Answer

Direct Messages stay in the Inbox even after your read or reply. It is best to delete a DM after you process it (in your case tweet it) so you don’t need to worry about it next time you fetch the messages.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement