mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-23 11:22:42 -06:00
add group chat sending and fix bugs
This commit is contained in:
parent
84fe9ed44a
commit
a4dbc56d8d
2 changed files with 13 additions and 9 deletions
19
demo.py
19
demo.py
|
@ -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')
|
||||
|
|
|
@ -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]
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue