added sending effects

This commit is contained in:
Chistopher Huntwork 2023-07-31 11:47:27 -07:00
parent 7b88754c01
commit 0049f11783
2 changed files with 13 additions and 1 deletions

13
demo.py
View file

@ -127,6 +127,7 @@ threading.Thread(target=input_thread, daemon=True).start()
print("Type 'help' for help") print("Type 'help' for help")
current_participants = [] current_participants = []
current_effect = None
while True: while True:
msg = im.receive() msg = im.receive()
if msg is not None: if msg is not None:
@ -140,10 +141,18 @@ while True:
print('quit (q): quit') print('quit (q): quit')
#print('send (s) [recipient] [message]: send a message') #print('send (s) [recipient] [message]: send a message')
print('filter (f) [recipient]: set the current chat') print('filter (f) [recipient]: set the current chat')
print('effect (e): adds an iMessage effect to the next sent message')
print('note: recipient must start with tel: or mailto: and include the country code') print('note: recipient must start with tel: or mailto: and include the country code')
print('\\: escape commands (will be removed from message)') print('\\: escape commands (will be removed from message)')
elif msg == 'quit' or msg == 'q': elif msg == 'quit' or msg == 'q':
break break
elif msg.startswith("effect ") or msg.startswith("e "):
msg = msg.split(" ")
if len(msg) < 2 or msg[1] == "":
print("effect [effect namespace]")
else:
print(f"next message will be sent with [{msg[1]}]")
current_effect = msg[1]
elif msg.startswith('filter ') or msg.startswith('f '): elif msg.startswith('filter ') or msg.startswith('f '):
# Set the curernt chat # Set the curernt chat
msg = msg.split(' ') msg = msg.split(' ')
@ -158,8 +167,10 @@ while True:
im.send(imessage.iMessage( im.send(imessage.iMessage(
text=msg, text=msg,
participants=current_participants, participants=current_participants,
sender=user.handles[0] sender=user.handles[0],
effect=current_effect
)) ))
current_effect = None
else: else:
print('No chat selected, use help for help') print('No chat selected, use help for help')

View file

@ -125,6 +125,7 @@ class iMessage:
"pv": 0, "pv": 0,
"gv": "8", "gv": "8",
"v": "1", "v": "1",
"iid": self.effect
} }
# Remove keys that are None # Remove keys that are None