diff options
author | Mark Powers <mark@marks.kitchen> | 2021-07-19 20:49:51 -0500 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2021-07-19 20:49:51 -0500 |
commit | dc62736d843949a4f6a01cbd1af09c25a38673a9 (patch) | |
tree | 7efe8f9add595cff625c3c4fc549ce38f35c80c7 /dial.py | |
parent | 5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 (diff) |
Refactor how some events work
Diffstat (limited to 'dial.py')
-rw-r--r-- | dial.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -58,18 +58,21 @@ class DialManager: self._load_sequences(phone_held, phone_hung_up) def _load_sequences(self, phone_held, phone_hung_up): - def recursive_add(classname, sequence_list, sequences): + def recursive_add(classname, sequence_list, sequences, args): key = int(sequence_list[0]) if not sequence_list[1:]: - sequences[key] = eval(classname)(self, phone_held, phone_hung_up) + sequences[key] = eval(classname)(self, phone_held, phone_hung_up, args) else: sequences[key] = {} - recursive_add(classname, sequence_list[1:], sequences[key]) + recursive_add(classname, sequence_list[1:], sequences[key], args) self.sequences = {} for sequence in config["sequences"]: print(sequence, config["sequences"][sequence], sep="\t") - recursive_add(config["sequences"][sequence], list(sequence), self.sequences) + parts = config["sequences"][sequence].split(" ", 1) + classname = parts[0] + args = parts[1:] + recursive_add(classname, list(sequence), self.sequences, args) def dial(self, number): if datetime.now() - self.update > timedelta(seconds=DIAL_RESET_TIME): |