Created
September 26, 2013 19:16
-
-
Save nilsding/6719163 to your computer and use it in GitHub Desktop.
Annoy your Twitter followers by tweeting the lyrics to "99 Bottles of Beer".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
# bottles_of_beer.py | |
# Annoy your Twitter followers by tweeting the lyrics to "99 Bottles of Beer". | |
# | |
# ---------------------------------------------------------------------------- | |
# "THE BEER-WARE LICENSE" (Revision 42): | |
# nilsding <nilsding@nilsding.org> wrote this file. As long as you retain this | |
# notice you can do whatever you want with this stuff. If we meet some day, | |
# and you think this stuff is worth it, you can buy me a beer in return. | |
# ---------------------------------------------------------------------------- | |
# | |
# Latest source code available at https://gist.github.com/nilsding/6719163 | |
# Get your OAuth keys from dev.twitter.com and set the permissions to Read/Write. | |
# I used consumer key and secrets from TweetDeck. Mention me (@nilsding) if you want to know them. | |
consumer_key = "" | |
consumer_secret = "" | |
access_token = "" | |
access_token_secret = "" | |
import tweepy | |
from time import sleep | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) | |
api = tweepy.API(auth) | |
bottles = 99 | |
while 1: | |
if bottles > 2: | |
text = '{0} bottles of beer on the wall, {0} bottles of beer.\nTake one down and pass it around, {1} bottles of beer on the wall.'.format(bottles, bottles - 1) | |
bottles -= 1 | |
elif bottles > 1: | |
text = '{0} bottles of beer on the wall, {0} bottles of beer.\nTake one down and pass it around, {1} bottle of beer on the wall.'.format(bottles, bottles - 1) | |
bottles -= 1 | |
elif bottles > 0: | |
text = '{0} bottle of beer on the wall, {0} bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.'.format(bottles) | |
bottles -= 1 | |
elif bottles == 0: | |
bottles = 99 | |
text = 'No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, {0} bottles of beer on the wall.'.format(bottles) | |
print text | |
try: | |
print api.update_status(status = text) | |
except tweepy.error.TweepError, err: | |
print api.update_status(status = text) | |
sleep(15) # sleep time in seconds, increase or decrease it if you want to. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment