Skip to content

Instantly share code, notes, and snippets.

@thricedotted
Last active August 29, 2015 14:05
Show Gist options
  • Save thricedotted/7644c576f41972134cbe to your computer and use it in GitHub Desktop.
Save thricedotted/7644c576f41972134cbe to your computer and use it in GitHub Desktop.
this script lets twitter tell u that ur a piece of shit in real time
from __future__ import unicode_literals
from twython import TwythonStreamer, TwythonError
import time
import pyttsx
# too lazy to ask twr for handle. u put ur handle here
MY_HANDLE = 'thricedotted'
# im shitty so i put my credentials in a plain file lol
with open('./.twittertest') as f: exec(f.read())
# if ur not shitty, put ur credentials here
#api_key = ''
#api_secret = ''
#access_token = ''
#access_token_secret = ''
# tts engine shit whatever
engine = pyttsx.init()
engine.setProperty('voice', 'english-us')
engine.setProperty('rate', 100)
engine.startLoop(False)
# ugh
def exclude_word(word):
return any(x in word for x in ('@', 'http'))
class ShitStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
# skip retweets
if data['text'].startswith('RT'):
return
# skip own tweets/DMs
if data['user']['screen_name'] == MY_HANDLE:
return
elif '@' + MY_HANDLE in data['text'].lower():
#print("Mention received")
#print(utterance)
utterance = ' '.join(w for w in data['text'].split() if not exclude_word(w)) + ", you piece of shit."
engine.say(utterance)
engine.iterate()
def on_error(self, status_code, data):
print(status_code)
shitstream = ShitStreamer(api_key, api_secret, access_token, access_token_secret)
shitstream.user()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment