messenger v0.9
This commit is contained in:
parent
5b54f3f636
commit
ae6bf0f96d
13 changed files with 105 additions and 115 deletions
9
mail.py
9
mail.py
|
|
@ -8,9 +8,10 @@ class Mail:
|
|||
"""Session interface for mailroom.
|
||||
|
||||
Two main IO methods. Will translate intents to mail and vice versa.
|
||||
Should be a parent class of Session.
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
self.crimata_id = False
|
||||
|
||||
# Receive intent.
|
||||
async def mailbox_recv(self):
|
||||
|
|
@ -21,6 +22,7 @@ class Mail:
|
|||
# Send intent.
|
||||
def mailbox_send(self, intent):
|
||||
mail = self.__encode(intent)
|
||||
print(f"Putting message into outbox {self.crimata_id}")
|
||||
mailroom.put_mail(self.crimata_id, mail)
|
||||
|
||||
def __encode(self, intent: typs.Intent) -> typs.Mail:
|
||||
|
|
@ -33,10 +35,11 @@ class Mail:
|
|||
|
||||
@staticmethod
|
||||
def __decode(mail: typs.Mail) -> typs.Intent:
|
||||
name = "notify"
|
||||
name = "message"
|
||||
params = {
|
||||
"owner": mail.owner,
|
||||
"text": mail.text #dev only
|
||||
}
|
||||
intent = typs.Intent(name, params)
|
||||
return intent
|
||||
|
||||
|
||||
Loading…
Reference in a new issue