Created
February 3, 2011 03:59
-
-
Save TelegramSam/809029 to your computer and use it in GitHub Desktop.
features that show what is up next
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
provides onnow, next |
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
rule joinofficehours { | |
select when twilio menuchoice Digits "5" | |
if ent:officehoursactive then { | |
twilio:say("Joining Office Hours. Press star to exit."); | |
twilio:dial_conference("officehours") with hangupOnStar = "true"; | |
} | |
fired { | |
raise explicit event EnsureRep; | |
} | |
} | |
rule nextofficehours { | |
select when twilio menuchoice Digits "5" | |
pre { | |
nextevent = kpublicevents:next("Office Hours"); | |
eventtitle = nextevent => verbaldate(nextevent.pick("$.when[0].start")) | "No Event Scheduled"; | |
} | |
if nextevent then { | |
twilio:say("Our next office hours session is #{eventtitle} Mountain Time."); | |
twilio:redirect("givemenu"); | |
} | |
notfired { | |
raise explicit event "NotScheduled"; | |
} | |
} | |
rule notscheduled { | |
select when explicit NotScheduled | |
{ | |
twilio:say("There are no office hours currently scheduled. Please check our website for more details."); | |
twilio:redirect("givemenu"); | |
} | |
} |
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
//returns either the next event with a matching title, or a 'falsy' value | |
next = function(title){ | |
start = time:now(); | |
end = time:add(start, {"days":30}); | |
requestoptions = caloptions.put({ | |
"start-min": time:atom(start), | |
"start-max": time:atom(end) | |
}); | |
onnow = http:get(calendarurl, requestoptions).pick("content").decode(); | |
allevents = onnow.pick("$..items[*]", true); | |
relevantevents = allevents.filter(function(e){e.pick("$.title") eq title}); | |
nextevent = relevantevents.head();//first event is next, because of sort order | |
nextevent; | |
}; |
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
verbaldate = function(d){ | |
datestringA = time:strftime(d, "%A, %d of %B at %I, %M %p"); | |
datestringB = datestringA.replace(re/ 0/g, " ").replace(re/ 0/g, " "); | |
datestringB; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment