|
|
|
@ -141,6 +141,42 @@ class Operator(Keymaker):
|
|
|
|
|
return Caller(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# return resp_msg_obj
|
|
|
|
|
|
|
|
|
|
def route(self,data,route):
|
|
|
|
|
if hasattr(self,route) and route in self.ROUTES:
|
|
|
|
|
func = getattr(self,route)
|
|
|
|
|
return func(**data)
|
|
|
|
|
|
|
|
|
|
def route_msg(self,msg_obj):
|
|
|
|
|
# decrypt
|
|
|
|
|
if msg_obj.is_encrypted:
|
|
|
|
|
msg_obj.decrypt()
|
|
|
|
|
# are there instructions for us?
|
|
|
|
|
if msg_obj.route:
|
|
|
|
|
# get result from routing
|
|
|
|
|
self.log(f'routing msg to self.{msg_obj.route}(**{msg_obj.data})')
|
|
|
|
|
response = self.route(msg_obj.data, route=msg_obj.route)
|
|
|
|
|
self.log('route response:',response)
|
|
|
|
|
# can we pass the buck on?
|
|
|
|
|
elif msg_obj.has_embedded_msg:
|
|
|
|
|
embedded_msg = msg_obj.msg
|
|
|
|
|
embedded_recipient = embedded_msg.to_whom
|
|
|
|
|
# whew, then we can make someone else take the phone
|
|
|
|
|
self.log(f'passing msg onto {embedded_recipient} ...')
|
|
|
|
|
|
|
|
|
|
response = embedded_recipient.route_msg(embedded_msg)
|
|
|
|
|
self.log(f'passed msg onto {embedded_recipient}, got this response: {response} ...')
|
|
|
|
|
# otherwise what are we doing?
|
|
|
|
|
else:
|
|
|
|
|
response = msg_obj
|
|
|
|
|
# ???
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ring_ring(self,msg,to_whom,get_resp_from=None):
|
|
|
|
|
# ring ring
|
|
|
|
|
self.log(f'''
|
|
|
|
@ -153,7 +189,10 @@ class Operator(Keymaker):
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
# get encr msg obj
|
|
|
|
|
msg_obj = self.compose_msg_to(msg, to_whom)
|
|
|
|
|
msg_obj = self.compose_msg_to(
|
|
|
|
|
msg,
|
|
|
|
|
to_whom
|
|
|
|
|
)
|
|
|
|
|
self.log(f'ring ring! here is the message object I made, to send to {to_whom}: {msg_obj}')
|
|
|
|
|
|
|
|
|
|
# encrypting
|
|
|
|
@ -172,37 +211,12 @@ class Operator(Keymaker):
|
|
|
|
|
|
|
|
|
|
return route_result
|
|
|
|
|
|
|
|
|
|
# return resp_msg_obj
|
|
|
|
|
|
|
|
|
|
def route(self,data,route):
|
|
|
|
|
if hasattr(self,route) and route in self.ROUTES:
|
|
|
|
|
func = getattr(self,route)
|
|
|
|
|
return func(**data)
|
|
|
|
|
|
|
|
|
|
def route_msg(self,msg_obj):
|
|
|
|
|
# decrypt
|
|
|
|
|
if msg_obj.is_encrypted:
|
|
|
|
|
msg_obj.decrypt()
|
|
|
|
|
# are there instructions for us?
|
|
|
|
|
if msg_obj.route:
|
|
|
|
|
# get result from routing
|
|
|
|
|
self.log(f'routing msg to self.{msg_obj.route}(**{msg_obj.data})')
|
|
|
|
|
response = self.route(msg_obj.data, route=msg_obj.route)
|
|
|
|
|
self.log('route response:',response)
|
|
|
|
|
# can we pass the buck on?
|
|
|
|
|
elif msg_obj.has_embedded_msg:
|
|
|
|
|
embedded_msg = msg_obj.msg
|
|
|
|
|
embedded_recipient = embedded_msg.to_whom
|
|
|
|
|
# whew, then we can make someone else take the phone
|
|
|
|
|
self.log(f'passing msg onto {embedded_recipient} ...')
|
|
|
|
|
|
|
|
|
|
response = embedded_recipient.route_msg(embedded_msg)
|
|
|
|
|
self.log(f'passed msg onto {embedded_recipient}, got this response: {response} ...')
|
|
|
|
|
# otherwise what are we doing?
|
|
|
|
|
else:
|
|
|
|
|
response = msg_obj
|
|
|
|
|
# ???
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pronto_pronto(self, msg_obj):
|
|
|
|
|
self.log(f'''
|
|
|
|
|