47 from CFTimeOfDay
import TimeOfDay
49 event = Crossfire.WhatIsEvent()
50 parameters = cjson.decode(event.Message)
51 alreadymatched = (event.Value!=0)
52 inverse =
"inverse" in parameters
and parameters[
"inverse"] ==
True
54 if not "match" in parameters:
55 Crossfire.Log(Crossfire.LogError,
"Script sleep.py didn't get a 'match' parameter. Only got %s" %parameters)
56 elif parameters[
"match"].lower() ==
"one":
57 match=
TimeOfDay().matchAny(parameters[
"when"]) != inverse
58 elif parameters[
"match"].lower() ==
"all":
59 match=
TimeOfDay().matchAll(parameters[
"when"]) != inverse
61 Crossfire.Log(Crossfire.LogError,
"Script sleep.py didn't get a 'match' parameter. Only got %s" %parameters)
63 if ( match != alreadymatched ):
64 Crossfire.Log(Crossfire.LogDebug,
"sleep")
65 event = Crossfire.WhatIsEvent()
66 current = Crossfire.WhoAmI()
71 Crossfire.Log(Crossfire.LogDebug,
"Awaken %s" %current.Name)
75 Crossfire.Log(Crossfire.LogDebug,
"Put %s to sleep" %current.Name)