read_profile(p, "/data/profiles/"+t)
def load_rules(file, p, event, who):
+ when = 0
try:
f = open(file)
l = f.readlines()
+ when = os.fstat(f.fileno()).st_mtime
except IOError:
l = []
for ln in l:
ln = ln.strip()
w = ln.split(':', 1)
- if len(w) == 2 and rule_matches(w[0].strip(), event, who):
+ if len(w) == 2 and rule_matches(w[0].strip(), event, who, when):
load_profile(p, w[1].strip())
def get_profile(event, who):
pass
return p
-def rule_matches(rule, event, who):
+def rule_matches(rule, event, who, when):
if rule == '':
return True
if rule == event:
return True
+ if rule[0] == '<' and rule[1:].isdigit():
+ return time.time() >= when and time.time() < when + int(rule[1:])*60
for w in who.split(' '):
if w[-8:] == rule[-8:]:
return True