Skip to content

Instantly share code, notes, and snippets.

@jonmarkgo
Created February 21, 2012 02:50
Show Gist options
  • Save jonmarkgo/1873222 to your computer and use it in GitHub Desktop.
Save jonmarkgo/1873222 to your computer and use it in GitHub Desktop.
Twilio Cat Facts by Akiva Bamberger
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)
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