Last active
January 17, 2018 14:03
-
-
Save snay2/1607554 to your computer and use it in GitHub Desktop.
Steve's ruleset
This file contains hidden or 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
ruleset a163x149 { | |
meta { | |
name "On-call TA: Steve" | |
description << | |
Handles the functions for Steve office hours | |
>> | |
author "Steve Nay" | |
logging off | |
use module a8x114 version "38" alias officehours with url = "{redacted}" | |
use module a8x115 alias twilio | |
use module a163x147 version "dev" alias funcs | |
} | |
dispatch { } | |
global { | |
///////////////////////////////////////////////////////////////////// | |
//Configure these two variables to match your name and phone number: | |
///////////////////////////////////////////////////////////////////// | |
my_name = "Steve"; | |
my_phone = "{redacted}"; | |
title = "/#{my_name}/"; | |
oncall_title = "/On-call: #{my_name}/"; | |
this_number = "{redacted}"; | |
} | |
rule schedule_inquiry_present { | |
select when explicit schedule_inquiry | |
pre { | |
person = event:param("person"); | |
thisevent = officehours:now(title); | |
endtime = thisevent => funcs:justtime(thisevent.pick("$.when[0].end")) | "later today"; | |
} | |
if thisevent then { | |
noop(); | |
} | |
fired { | |
raise explicit event present with person=person and end=endtime; | |
} | |
} | |
rule schedule_inquiry_oncall { | |
select when explicit schedule_inquiry | |
pre { | |
person = event:param("person"); | |
thisevent = officehours:now(oncall_title); | |
endtime = thisevent => funcs:justtime(thisevent.pick("$.when[0].end")) | "later today"; | |
} | |
if thisevent then{ | |
noop(); | |
} | |
fired { | |
raise explicit event on_call_request with person=person and end=endtime; | |
} | |
} | |
//////////////////////////////////////////////////////////////////////////// | |
// Modify the rules below to suit your liking. Examples are given with SMS. | |
//////////////////////////////////////////////////////////////////////////// | |
// Tell the student that the TA should already be in the cubicle | |
rule present { | |
select when explicit present | |
pre { | |
person = event:param("person"); | |
end = event:param("end"); | |
} | |
twilio:sms("#{my_name} should be in the office right now until #{end}"); | |
} | |
// Tell the student that the TA has been paged | |
rule sms_student { | |
select when explicit on_call_request | |
pre { | |
end = event:param("end"); | |
} | |
twilio:sms("#{my_name} has been notified and will arrive shortly in Cubicle 11. He is on call until #{end}."); | |
} | |
// Tell the TA that he is being paged by a student | |
rule sms_ta { | |
select when explicit on_call_request | |
pre { | |
person = event:param("person"); | |
end = event:param("end"); | |
} | |
twilio:sms("You are being hailed by #{person}. They are requesting a rendezvous in Cubicle 11. Your duty shift goes until #{end}.") with to=my_phone; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment