add group chat sending and fix bugs

This commit is contained in:
JJTech0130 2023-07-31 13:57:50 -04:00
parent 84fe9ed44a
commit a4dbc56d8d
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6
2 changed files with 13 additions and 9 deletions

19
demo.py
View file

@ -126,10 +126,10 @@ threading.Thread(target=input_thread, daemon=True).start()
print("Type 'help' for help")
current_chat = None
current_participants = []
while True:
msg = im.receive()
if msg is not None and msg.sender != user.handles[0]:
if msg is not None:
print(f'[{msg.sender}] {msg.text}')
if len(INPUT_QUEUE) > 0:
@ -144,20 +144,21 @@ while True:
print('\\: escape commands (will be removed from message)')
elif msg == 'quit' or msg == 'q':
break
elif msg.startswith('filter') or msg.startswith('f'):
elif msg.startswith('filter ') or msg.startswith('f '):
# Set the curernt chat
msg = msg.split(' ')
if len(msg) < 2:
print('filter [recipient]')
if len(msg) < 2 or msg[1] == '':
print('filter [recipients]')
else:
current_chat = msg[1]
elif current_chat is not None:
print(f'Filtering to {msg[1:]}')
current_participants = msg[1:]
elif current_participants != []:
if msg.startswith('\\'):
msg = msg[1:]
im.send(imessage.iMessage(
text=msg,
participants=[current_chat, user.handles[0]],
#sender=user.handles[0]
participants=current_participants,
sender=user.handles[0]
))
else:
print('No chat selected, use help for help')

View file

@ -386,6 +386,9 @@ class iMessageUser:
bundled_payloads = []
for participant in message.participants:
for push_token in self.USER_CACHE[participant]:
if push_token == self.connection.token:
continue # Don't send to ourselves
identity_keys = ids.identity.IDSIdentity.decode(
self.KEY_CACHE[push_token][0]
)