|
|
@@ -62,6 +62,7 @@ def setConfiguration(self): |
|
|
self.group_callout_chance = settings["callouts"]["groupCalloutChance"]
|
|
|
self.channel_id = settings["channelId"]
|
|
|
self.exercises = settings["exercises"]
|
|
|
+ self.office_hours_on = settings["officeHours"]["on"]
|
|
|
self.office_hours_begin = settings["officeHours"]["begin"]
|
|
|
self.office_hours_end = settings["officeHours"]["end"]
|
|
|
|
|
|
@@ -191,15 +192,15 @@ def assignExercise(bot, exercise): |
|
|
exercise_reps = random.randrange(exercise["minReps"], exercise["maxReps"]+1)
|
|
|
|
|
|
winner_announcement = str(exercise_reps) + " " + str(exercise["units"]) + " " + exercise["name"] + " RIGHT NOW "
|
|
|
-
|
|
|
+
|
|
|
# EVERYBODY
|
|
|
if random.random() < bot.group_callout_chance:
|
|
|
winner_announcement += "@channel!"
|
|
|
|
|
|
for user_id in bot.user_cache:
|
|
|
user = bot.user_cache[user_id]
|
|
|
user.addExercise(exercise, exercise_reps)
|
|
|
-
|
|
|
+
|
|
|
logExercise(bot,"@channel",exercise["name"],exercise_reps,exercise["units"])
|
|
|
|
|
|
else:
|
|
|
@@ -263,12 +264,20 @@ def saveUsers(bot): |
|
|
pickle.dump(bot.user_cache,f)
|
|
|
|
|
|
def isOfficeHours(bot):
|
|
|
+ if not bot.office_hours_on:
|
|
|
+ if bot.debug:
|
|
|
+ print "not office hours"
|
|
|
+ return True
|
|
|
now = datetime.datetime.now()
|
|
|
now_time = now.time()
|
|
|
if now_time >= datetime.time(bot.office_hours_begin) and now_time <= datetime.time(bot.office_hours_end):
|
|
|
+ if bot.debug:
|
|
|
+ print "in office hours"
|
|
|
return True
|
|
|
else:
|
|
|
- return False;
|
|
|
+ if bot.debug:
|
|
|
+ print "out office hours"
|
|
|
+ return False
|
|
|
|
|
|
def main():
|
|
|
bot = Bot()
|
|
|
@@ -286,9 +295,12 @@ def main(): |
|
|
assignExercise(bot, exercise)
|
|
|
|
|
|
else:
|
|
|
- # Sleep and check again for office hours
|
|
|
- time.sleep(5*60) # Sleep 5 minutes
|
|
|
-
|
|
|
+ # Sleep the script and check again for office hours
|
|
|
+ if not bot.debug:
|
|
|
+ time.sleep(5*60) # Sleep 5 minutes
|
|
|
+ else:
|
|
|
+ # If debugging, check again in 5 seconds
|
|
|
+ time.sleep(5)
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
saveUsers(bot)
|
|
|
|
0 comments on commit
b18d80c