Created
April 30, 2011 19:36
-
-
Save jvimal/949923 to your computer and use it in GitHub Desktop.
linking up
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
# add it at the end of users.py | |
def linkup(): | |
"""Links up two random people from the waiting list.""" | |
num_waiting = r.scard('waiting') | |
if num_waiting < 2: | |
# Cannot link up | |
return False | |
num1 = r.spop('waiting') | |
num2 = r.spop('waiting') | |
# our routing table | |
r.set(num1, num2) | |
r.set(num2, num1) | |
text = "You're now connected to a random stranger!" | |
send_sms(num1, text) | |
send_sms(num2, text) | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment