Context 1: (widget)
if %NIGHT is set
Wifi set on
variable clear %LAST
variable clear %NIGHT
silent mode off
say "Good morning!"
mobile data ON
stop
end if
****the below will run if %NIGHT is not set, and hence will ACTIVATE %NIGHT****
Silent mode off
variable set %NIGHT to 1
variable set %LAST to 1
say "Goodnight!"
silent mode ON
media volume 0
mobile data OFF
wifi OFF
Context 2: NightSMS
Event->received text
variable value -> %NIGHT = 1
if %SMSRF > 100000000 (to make sure that facebook notifications don't receive an autoreply)
if %SMSRF != %LAST (so it only sends to that # once if he texts 5 times in a row)
variable set %LAST = %SMSRF
Send SMS, number=%SMSRF, message="sleeping! I'll reply when I'm up!"
end if
end if
Context 3: NightCALL
event->phone ringing
variable value->%NIGHT = 1
end call