Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. import time
  2. from twilio.rest import TwilioRestClient
  3. from googlemaps import GoogleMaps
  4. import urllib
  5. import webbrowser
  6. import nudgely_user
  7.  
  8.  
  9. #Initialize variables
  10. expected_steps = 0
  11. now = 0
  12. steps = 0
  13. remaining_steps = 0
  14. total_texts = 0
  15. name = None
  16. user = None
  17. address = None
  18. cell = 0
  19.  
  20. user1 = nudgely_user.NudgelyUser(name, steps, address, cell)
  21.  
  22.  
  23. #Introduce program to user. Find the local time.Convert to an integer. Determine how many texts to send. (More on that later.)
  24. def userIntro():
  25. remaining_steps = 0
  26. global user1
  27. tm_year,tm_mon,tm_mday,tm_hour,tm_min=map(str,time.localtime()[:5])
  28. now = int(tm_hour)
  29. total_texts = int((24 - int(now))/2)
  30. print "Greetings."
  31. print " "
  32. time.sleep(1)
  33. user1.name = raw_input("What's your name? ")
  34. print " "
  35. print "Howdy, " +user1.name+ ". It's very nice to meet you."
  36. time.sleep(2)
  37. print " "
  38. print "My name is Nudgely.(Pronounced NUDGE-LEE)"
  39. print " "
  40. time.sleep (2)
  41. print "I'm going to help you take 10,000 steps today."
  42. time.sleep(2)
  43. print " "
  44. print "The current time is around " +str(now)+ " hundred hours (as they say in the military)."
  45. print " "
  46. time.sleep(3)
  47. if int(now) >= 7:
  48. expected_steps = (now * 250)
  49. else:
  50. expected_steps = 0
  51. print "I'm guessing you've taken around "+str(expected_steps)+" steps so far today."
  52. print " "
  53. time.sleep(3)
  54.  
  55. #error handling for non-number inputs for number of steps question
  56. #while True:
  57. user1.steps = raw_input("How many steps have you actually taken? (If you don't know, just take a guess.) ")
  58. #this next line checks for valid input
  59.  
  60. remaining_steps = (10000 - int(user1.steps))/(24-int(now))
  61.  
  62. if int(user1.steps) < int(expected_steps):
  63. print " "
  64. print "You're a little behind; but, don't worry! You can do this."
  65. print " "
  66. time.sleep(2)
  67. print "DEADLINE = MIDNIGHT."
  68. print " "
  69. time.sleep(2)
  70. print "GOAL = "+str(remaining_steps)+" STEPS per HOUR UNTIL MIDNIGHT."
  71. print " "
  72. time.sleep(2)
  73. print "Let's get started."
  74. print " "
  75. time.sleep(2)
  76. elif int(steps) >10000:
  77. print " "
  78. print "You are a MACHINE. You have already hit your goal. Let's see if we can set a personal record."
  79. print " "
  80. time.sleep(2)
  81. else:
  82. print " "
  83. print "En fuego! You are ahead of schedule."
  84. print " "
  85. time.sleep(2)
  86. print "You need just " +str(remaining_steps)+" steps per hour to hit your goal by midnight."
  87. print " "
  88. time.sleep(2)
  89. print "Let's put together a plan."
  90. print " "
  91. time.sleep(2)
  92.  
  93.  
  94. #Enable user to come up with a walking plan by show nearby walking options.
  95. def showWalkingTrails():
  96. global user1
  97. user1.address = raw_input("What city and state are you in right now? ")
  98. print " "
  99. time.sleep(1)
  100. url="https://www.google.com/maps/search/walking+trails/?address=%s" % user1.address
  101. print "Cool. I've found some nearby walking options based on your IP address."
  102. print " "
  103. time.sleep(2)
  104. print "I'm going to launch your browser so you can take a look at them."
  105. print " "
  106. time.sleep(3)
  107. webbrowser.open(url)
  108.  
  109.  
  110.  
  111. #Send text reminders
  112. def sendText():
  113. global user1
  114.  
  115. print "********************************************************************"
  116. time.sleep(5)
  117. print " "
  118. print "Welcome back."
  119. print " "
  120. keep_going = raw_input("Ready to keep going? ")
  121. print " "
  122. keep_going_responses = ("yes", "Yes", "YES", "y", "Y", "YE", "ye","sure","ok","OK","Okay")
  123.  
  124. tm_year,tm_mon,tm_mday,tm_hour,tm_min=map(str,time.localtime()[:5])
  125. now = int(tm_hour)
  126. total_texts = int((24 - int(now))/2)
  127.  
  128. if keep_going in keep_going_responses:
  129. print "Great. Now that we've put our plan together, let's make sure we stick to it."
  130. print " "
  131. time.sleep(2)
  132. print "I'm also going to send you a friendly text reminders every two hours until midnight"
  133. print " "
  134. time.sleep(3)
  135. else:
  136. print "We're going to keep going anyway. Let's set you up with some reminders."
  137.  
  138. user1.cell = raw_input ("What is your cell phone number? ")
  139. print " "
  140. print "Got it. You are all set. The texts are locked and loaded."
  141. print " "
  142. time.sleep(1)
  143. print "It has certainly been a pleasure chatting with you " +user1.name
  144. time.sleep(1)
  145. print " "
  146. print "Nudgely out."
  147. print " "
  148. time.sleep(2)
  149. print "Walk on!"
  150.  
  151. user1.send_text()
  152.  
  153. #for i in range(total_texts):
  154. #time.sleep(7200)
  155. #account_sid = "AC6ed6d9360f4e58d793f518a41e93bf7e"
  156. #auth_token = "a32cd19c609802c2b819a932dd046cdf"
  157. #client = TwilioRestClient(account_sid, auth_token)
  158.  
  159. #message = client.messages.create(body="Keep moving! Great job! Your friend, Nudgely.",
  160. # to="+1"+user1.cell,
  161. # from_="+17042084886")
  162.  
  163.  
  164.  
  165. userIntro()
  166. showWalkingTrails()
  167. sendText()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement