@IPv6fail: Noting the Irony of #IPv6 Tweets

This is a bot which searches the Twitter public timeline for mentions of IPv6. Any URLs mentioned in those tweets whose hosts do not have an AAAA record (i.e. do not have IPv6 support) are clearly meant to be ironic, for why would anyone be commenting on IPv6 if they've not tried to deploy it yet? Your irony is @IPv6fail's invitation to jokingly lament the lack of support for a decade-old networking protocol by the content provider in question.

IPv6fail takes a lot of care to not repeatedly tweet about one particular host or at one particular user. The logic is reproduced in annotated form below:

# having parsed the URLs out of tweets mentioning IPv6, unshorten
# and follow HTTP redirects to the final location
getter = urllib2.urlopen( url )
turl = getter.url

# only proceed if this is a new URL
if not queue.isDone( turl ):
    ( _, host, _, _, _, _ ) = urllib2.urlparse.urlparse( turl )

    # count how many times we've sent a tweet about this host
    # or replied to this user
    count = ( queue.countHost( host ) +
              queue.countUser( tweet.user.screen_name ))

    # we're only going to tweet if there is
    # no IPv6 support for target URL
    v6 = host_has_v6( host )
    messaged = not v6

    # reduce how annoying we are with
    # a probabilistic and reciprocal approach
    if count:
if random.random() > ( 1/count ):
            messaged = False

    # URLs, their IPv6 support, and whether we
    # messaged about it are stored in the database
    queue.set( tweet.id, tweet.user.screen_name,
               url, host, v6, messaged )
    queue.set( tweet.id, tweet.user.screen_name,
               turl, host, v6, messaged )

    if messaged:
     api.PostUpdate( u"blahblahblahblahblah",
                        in_reply_to_status_id = tweet.id )

Category: