Stop Twitter Direct Messages

My relationship with Twitter ebbs and flows. Sometimes I find it very enjoyable, and at other times it seems like a worthless distraction. However, there is one part of Twitter that I have never liked, direct messages.

Why not like direct messages? I’m not a fan of anything that creates another queue that I have to monitor and respond to. I try to keep everything in one workflow, and that workflow is email. My annoyance isn’t limited to Twitter direct messages, but extends equally to Facebook messages and any other website specific inbox. I think Facebook could actually do their members a huge service by making their message system IMAP-capable. It would make it infinitely more useful and you could happily sit in your choice of email clients. On the other hand I would rather just not deal with Twitter direct messages.

I’d thought for a while that part of a Twitter Pro premium service could be to turn off direct message function. I decided to take matters into my own hands and rid myself of direct messages now instead. You can use this little program to do the same for you.

The first thing to do is tell Twitter to stop notifying you of a direct message. Go to your account Settings and in the Notices tab uncheck the Direct Text emails option.

direct-text-email-setting.png

Now, this 28-line Ruby program will simply respond (via direct message) to any direct messages you have received and then delete the direct message from your account, leaving no queue behind. If you don’t like the delete, you can just comment out line 24. To make life easy this uses the Twitter4R library for Ruby. You will have to edit lines 9 and 19 to your credentials and personal message.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Get requires out of the way
require('rubygems')
gem('twitter4r', '>=0.2.0')
require('twitter')
require('time')
 
# Let's get a Twitter Client created
# TODO: Put your credentials in here
client = Twitter::Client.new(:login => 'USERNAME', :password => 'PASSWORD')
 
# Get Direct Messages
messages = client.messages(:received)
 
# Loop through any direct messages received
messages.each do |message|
  # Reply to the message
  # TODO: set the message text to what you want, make sure it is Twitter length compliant
  response = Twitter::Message.create(
    :text => 'PUT YOUR MESSAGE HERE. YOU PROBABLY WANT YOUR EMAIL IN HERE.',
    :recipient => message.sender,
    :client => client)
 
  # Delete the message
  client.message(:delete, message)
 
  # Put a brief pause here just to make Twitter happier
  sleep 5
end

There is no error checking and by default it outputs nothing. It is intended to be invoked via cron at whatever interval you would like. If you do not have the Twitter4R Gem installed just run gem install twitter4r.

6 thoughts on “Stop Twitter Direct Messages

  1. Jamie,

    Pretty neat easy to run program. However, I don’t find the DM as annoying as some, mainly because I do not check it on a regular basis. On Twitter, when I click to check it, I click to check it. Hopefully people learn that I do not use it like email. I thought it was a good feature when I used to be able to set DMs as a text message. I miss the text alerting capabilities of the original Twitter (before the issues).

    As for the email system, while I can agree that the most user friendly thing to do would be to support IMAP, that would remove one of the key values to offering the service to begin with: bring users back to the service to respond and hopefully see any new enhancements that can increase repeat visits and higher overall user utility. I think FB did the right thing by putting the message of the sender in the email notification, that is a lot more user friendly than “click here to see the message”.

    • @Lou,

      I’ve had a couple of direct messages fall through the cracks lately. I might go a couple of days or longer without looking at Twitter in any manner where I can see a direct message and have missed them.

      There is one use that even I get out of DM’s though, and that is getting email addresses if I don’t have it. Luckily my bot autoresponder will provide that on my behalf. ;-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">