minor improvments
This commit is contained in:
parent
2287ddd6f1
commit
db2e6c4f15
14 changed files with 39 additions and 120 deletions
27
mail.py
27
mail.py
|
|
@ -10,8 +10,8 @@ class Mail:
|
|||
Two main IO methods. Will translate intents to mail and vice versa.
|
||||
Should be a parent class of Session.
|
||||
"""
|
||||
def __init__(self):
|
||||
self.crimata_id = False
|
||||
def __init__(self, crimata_id):
|
||||
self.crimata_id = crimata_id
|
||||
|
||||
# Receive intent.
|
||||
async def mailbox_recv(self):
|
||||
|
|
@ -20,27 +20,26 @@ class Mail:
|
|||
return intent
|
||||
|
||||
# Send intent.
|
||||
def mailbox_send(self, intent):
|
||||
mail = self.__encode(intent)
|
||||
def mailbox_send(self, jpackage):
|
||||
mail = self.__encode(jpackage)
|
||||
print(f"Putting message into outbox {self.crimata_id}")
|
||||
mailroom.put_mail(self.crimata_id, mail)
|
||||
|
||||
def __encode(self, intent: typs.Intent) -> typs.Mail:
|
||||
p = intent.params
|
||||
def __encode(self, jpackage) -> typs.Mail:
|
||||
j = jpackage
|
||||
owner = self.crimata_id
|
||||
target = p.get("target")
|
||||
text = p.get("text")
|
||||
audio = p.get("audio")
|
||||
target = j.get("target")
|
||||
print(target)
|
||||
text = j.get("text")
|
||||
audio = j.get("audio")
|
||||
mail = typs.Mail(owner, target, text, audio)
|
||||
return mail
|
||||
|
||||
@staticmethod
|
||||
def __decode(mail: typs.Mail) -> typs.Intent:
|
||||
name = "message"
|
||||
params = {
|
||||
def __decode(mail: typs.Mail):
|
||||
jpackage = {
|
||||
"owner": mail.owner,
|
||||
"text": mail.text, #dev only
|
||||
"audio": mail.audio
|
||||
}
|
||||
intent = typs.Intent(name, params)
|
||||
return intent
|
||||
return jpackage
|
||||
Loading…
Reference in a new issue