Skip to content

Commit

Permalink
got noises off working
Browse files Browse the repository at this point in the history
  • Loading branch information
prehensile committed Jun 17, 2012
1 parent 8b38314 commit 486cc4f
Show file tree
Hide file tree
Showing 15 changed files with 3,113 additions and 11 deletions.
21 changes: 14 additions & 7 deletions messages/streetnoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
import random

incoming_status_templates = [
Template( "/me stiffens as $name thumps on the wall and yells something about $message." ),
Template( "/me digs out the phone from under a pile of empties, listens for a second then yells out something about $name and $message." ),
Template( "/me chases $name away from the windows with a broom. They yell something about $message over their shoulder in parting." ),
Template( "/me finds $name hiding in the bogs, mumbling something about $message." )
Template( "/me stiffens as $name thumps on the wall and yells something \
about $message." ),
Template( "/me digs out the phone from under a pile of empties, listens for \
a second then yells out something about $name and $message." ),
Template( "/me chases $name away from the windows with a broom. They yell \
something about $message over their shoulder in parting." ),
Template( "/me finds $name hiding in the bogs, mumbling something about \
$message." ),
Template( "/me catches a brick as it flies in through a front window. \
There's a note wrapped around it from $name. The crayon is badly \
smudged, but it's possible to make out something about $message." )
]

muffle_words = [ "something", "worple", "blah" ]
muffle_words = [ "something", "blah" ]

def message_for_incoming_status( status ):
# muffle text
muffle_amount = 0.3 # muffle a third of input words
muffle_amount = 0.4 # muffle a 40% of input words
words = status.text.split(" ")
num_words = len(words)
# get a list of references to status words
Expand All @@ -28,7 +35,7 @@ def message_for_incoming_status( status ):
words[ index ] = random.choice( muffle_words )
message = " ".join( words )
# remove trailing punctuation from message
message.rstrip(".?!")
message = message.rstrip(".?!")
# get author name
name = "@%s" % status.author.screen_name
# choose a template
Expand Down
4 changes: 2 additions & 2 deletions skypebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ def run( self ):
if ENABLE_TWITTER:
new_statuses = self.twitter_connector.pop_stream()
for status_in in new_statuses:

try:
message_out = streetnoise.message_for_incoming_status( status_in )
logging.info( message_out )
self.message_all( message )
self.twitter_connector.tweet( message_out )
except Exception, e:
logging.info( e )

Expand Down
27 changes: 27 additions & 0 deletions tweepy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Tweepy
# Copyright 2009-2010 Joshua Roesslein
# See LICENSE for details.

"""
Tweepy Twitter API library
"""
__version__ = '1.9'
__author__ = 'Joshua Roesslein'
__license__ = 'MIT'

from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory
from tweepy.error import TweepError
from tweepy.api import API
from tweepy.cache import Cache, MemoryCache, FileCache
from tweepy.auth import BasicAuthHandler, OAuthHandler
from tweepy.streaming import Stream, StreamListener
from tweepy.cursor import Cursor

# Global, unauthenticated instance of API
api = API()

def debug(enable=True, level=1):

import httplib
httplib.HTTPConnection.debuglevel = level

Loading

0 comments on commit 486cc4f

Please sign in to comment.