Created
February 21, 2012 02:50
-
-
Save jonmarkgo/1873222 to your computer and use it in GitHub Desktop.
Twilio Cat Facts by Akiva Bamberger
This file contains hidden or 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
def call_people(self, newbie): | |
self.call_person(newbie) | |
# send 5 texts to people who haven't gotten one in over 4 hours | |
people = Numbers.gql("WHERE last_touched < :1", last_time()).fetch(5) | |
for person in people: | |
self.call_person(person) |
This file contains hidden or 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
def call_person(self, person): | |
SIZE = 155 | |
fact = catfacts() | |
account = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx4f" | |
token = "72xxxxxxxxxxxxxxxxxxxxxxxxxxxx3a" | |
client = TwilioRestClient(account, token) | |
num_messages = len(fact) / SIZE + 1 | |
if num_messages == 1: | |
client.sms.messages.create(to="+1"+person.number, from_="+18053228518", | |
body=fact ) | |
else: | |
for i in xrange(num_messages): | |
client.sms.messages.create(to="+1"+person.number, from_="+18053228518", | |
body="%d/%d: %s" % ((i+1), | |
num_messages, fact[i*155:((i+1)*155)] )) | |
person.count = person.count + 1 | |
if person.count >= MAX_COUNT: | |
db.delete(person) | |
return | |
person.put() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment