aboutsummaryrefslogtreecommitdiff
path: root/dial.py
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2021-07-19 20:49:51 -0500
committerMark Powers <mark@marks.kitchen>2021-07-19 20:49:51 -0500
commitdc62736d843949a4f6a01cbd1af09c25a38673a9 (patch)
tree7efe8f9add595cff625c3c4fc549ce38f35c80c7 /dial.py
parent5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 (diff)
Refactor how some events work
Diffstat (limited to 'dial.py')
-rw-r--r--dial.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/dial.py b/dial.py
index 8fc92a9..d5117ff 100644
--- a/dial.py
+++ b/dial.py
@@ -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):