mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-23 11:22:42 -06:00
added logging of message effects
This commit is contained in:
parent
c87d188c95
commit
232e126a89
2 changed files with 11 additions and 4 deletions
2
demo.py
2
demo.py
|
@ -130,7 +130,7 @@ current_participants = []
|
||||||
while True:
|
while True:
|
||||||
msg = im.receive()
|
msg = im.receive()
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
print(f'[{msg.sender}] {msg.text}')
|
print(msg.to_string())
|
||||||
|
|
||||||
if len(INPUT_QUEUE) > 0:
|
if len(INPUT_QUEUE) > 0:
|
||||||
msg = INPUT_QUEUE.pop()
|
msg = INPUT_QUEUE.pop()
|
||||||
|
|
13
imessage.py
13
imessage.py
|
@ -53,6 +53,8 @@ class iMessage:
|
||||||
"""Group ID of the message, will be randomly generated if not provided"""
|
"""Group ID of the message, will be randomly generated if not provided"""
|
||||||
body: BalloonBody | None = None
|
body: BalloonBody | None = None
|
||||||
"""BalloonBody, may be None"""
|
"""BalloonBody, may be None"""
|
||||||
|
effect: str | None = None
|
||||||
|
"""iMessage effect sent with this message, may be None"""
|
||||||
|
|
||||||
_compressed: bool = True
|
_compressed: bool = True
|
||||||
"""Internal property representing whether the message should be compressed"""
|
"""Internal property representing whether the message should be compressed"""
|
||||||
|
@ -103,9 +105,8 @@ class iMessage:
|
||||||
sender=message.get("p", [])[-1] if message.get("p", []) != [] else None,
|
sender=message.get("p", [])[-1] if message.get("p", []) != [] else None,
|
||||||
_id=uuid.UUID(message.get("r")) if "r" in message else None,
|
_id=uuid.UUID(message.get("r")) if "r" in message else None,
|
||||||
group_id=uuid.UUID(message.get("gid")) if "gid" in message else None,
|
group_id=uuid.UUID(message.get("gid")) if "gid" in message else None,
|
||||||
body=BalloonBody(message["bid"], message["b"])
|
body=BalloonBody(message["bid"], message["b"]) if "bid" in message else None,
|
||||||
if "bid" in message
|
effect=message["iid"] if "iid" in message else None,
|
||||||
else None,
|
|
||||||
_compressed=compressed,
|
_compressed=compressed,
|
||||||
_raw=message,
|
_raw=message,
|
||||||
)
|
)
|
||||||
|
@ -138,6 +139,12 @@ class iMessage:
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def to_string(self) -> str:
|
||||||
|
message_str = f"[{self.sender}] '{self.text}'"
|
||||||
|
if self.effect is not None:
|
||||||
|
message_str += f" with effect [{self.effect}]"
|
||||||
|
return message_str
|
||||||
|
|
||||||
|
|
||||||
class iMessageUser:
|
class iMessageUser:
|
||||||
"""Represents a logged in and connected iMessage user.
|
"""Represents a logged in and connected iMessage user.
|
||||||
|
|
Loading…
Reference in a new issue