mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-23 03:15:15 -06:00
aaargh
This commit is contained in:
parent
3c72c3d56e
commit
c90448f658
3 changed files with 368 additions and 115 deletions
89
demo.py
89
demo.py
|
@ -108,44 +108,61 @@ with open("config.json", "w") as f:
|
|||
|
||||
im = imessage.iMessageUser(conn, user)
|
||||
|
||||
# Create a thread to take user input
|
||||
INPUT_QUEUE = apns.IncomingQueue()
|
||||
|
||||
def input_thread():
|
||||
while True:
|
||||
from prompt_toolkit import prompt
|
||||
|
||||
try:
|
||||
msg = prompt('>> ')
|
||||
except:
|
||||
msg = 'quit'
|
||||
INPUT_QUEUE.append(msg)
|
||||
|
||||
threading.Thread(target=input_thread, daemon=True).start()
|
||||
|
||||
|
||||
while True:
|
||||
msg = im.receive()
|
||||
if msg is not None:
|
||||
print(f"Got message {msg}")
|
||||
|
||||
if len(INPUT_QUEUE) > 0:
|
||||
msg = INPUT_QUEUE.pop()
|
||||
if msg == 'help' or msg == 'h':
|
||||
print('help (h): show this message')
|
||||
print('quit (q): quit')
|
||||
print('send (s) [recipiant] [message]: send a message')
|
||||
elif msg == 'quit' or msg == 'q':
|
||||
break
|
||||
elif msg.startswith('send') or msg.startswith('s'):
|
||||
msg = msg.split(' ')
|
||||
if len(msg) < 3:
|
||||
print('send [recipiant] [message]')
|
||||
else:
|
||||
# while True:
|
||||
# i = im.receive()
|
||||
# if i is not None:
|
||||
# print(f"Got message {i}")
|
||||
imsg = imessage.iMessage()
|
||||
imsg.text = ' '.join(msg[2:])
|
||||
imsg.participants = [msg[1], user.handles[0]]
|
||||
imsg.sender = user.handles[0]
|
||||
imsg.participants = ["mailto:jjtech@jjtech.dev"]
|
||||
imsg.text = "Hello world!"
|
||||
|
||||
time.sleep(1)
|
||||
im.send(imsg)
|
||||
|
||||
for i in range(10):
|
||||
z = im.receive()
|
||||
if z is not None:
|
||||
print(f"Got message {z}")
|
||||
time.sleep(1)
|
||||
# # Create a thread to take user input
|
||||
# INPUT_QUEUE = apns.IncomingQueue()
|
||||
|
||||
# def input_thread():
|
||||
# while True:
|
||||
# from prompt_toolkit import prompt
|
||||
|
||||
# try:
|
||||
# msg = prompt('>> ')
|
||||
# except:
|
||||
# msg = 'quit'
|
||||
# INPUT_QUEUE.append(msg)
|
||||
|
||||
# threading.Thread(target=input_thread, daemon=True).start()
|
||||
|
||||
|
||||
# while True:
|
||||
# msg = im.receive()
|
||||
# if msg is not None:
|
||||
# print(f"Got message {msg}")
|
||||
|
||||
# if len(INPUT_QUEUE) > 0:
|
||||
# msg = INPUT_QUEUE.pop()
|
||||
# if msg == 'help' or msg == 'h':
|
||||
# print('help (h): show this message')
|
||||
# print('quit (q): quit')
|
||||
# print('send (s) [recipiant] [message]: send a message')
|
||||
# elif msg == 'quit' or msg == 'q':
|
||||
# break
|
||||
# elif msg.startswith('send') or msg.startswith('s'):
|
||||
# msg = msg.split(' ')
|
||||
# if len(msg) < 3:
|
||||
# print('send [recipiant] [message]')
|
||||
# else:
|
||||
# imsg = imessage.iMessage()
|
||||
# imsg.text = ' '.join(msg[2:])
|
||||
# imsg.participants = [msg[1], user.handles[0]]
|
||||
# imsg.sender = user.handles[0]
|
||||
|
||||
# im.send(imsg)
|
||||
|
||||
|
|
|
@ -219,7 +219,9 @@ def pretty_print_payload(
|
|||
|
||||
if topic == "com.apple.madrid":
|
||||
print(f" {bcolors.FAIL}Madrid{bcolors.ENDC}", end="")
|
||||
orig_payload = payload
|
||||
payload = plistlib.loads(_get_field(payload[1], 3))
|
||||
|
||||
# print(payload)
|
||||
if "cT" in payload and False:
|
||||
# It's HTTP over APNs
|
||||
|
@ -248,10 +250,30 @@ def pretty_print_payload(
|
|||
if b"plist" in body:
|
||||
body = plistlib.loads(body)
|
||||
print(f" {bcolors.FAIL}Body{bcolors.ENDC}: {body}", end="")
|
||||
if not "cT" in payload:
|
||||
#if not "cT" in payload:
|
||||
for key in payload:
|
||||
print(f" {bcolors.OKBLUE}{key}{bcolors.ENDC}: {payload[key]}")
|
||||
|
||||
if 'dtl' in payload:
|
||||
print("OVERRIDE DTL")
|
||||
payload['dtl'][0].update({'sT': b64decode("jJ86jTYbv1mGVwO44PyfuZ9lh3o56QjOE39Jk8Z99N8=")})
|
||||
|
||||
# Re-serialize the payload
|
||||
payload = plistlib.dumps(payload, fmt=plistlib.FMT_BINARY)
|
||||
# Construct APNS message
|
||||
# Get the original fields except 3
|
||||
fields = orig_payload[1]
|
||||
fields = [field for field in fields if field[0] != 3]
|
||||
# Add the new field
|
||||
fields.append((3, payload))
|
||||
payload = apns._serialize_payload(0xA, fields)
|
||||
|
||||
# Use the override payload
|
||||
|
||||
#print(payload, orig_payload)
|
||||
#print(payload == orig_payload)
|
||||
return payload
|
||||
|
||||
print()
|
||||
|
||||
# print(f" {bcolors.WARNING}{bcolors.ENDC}: {payload['cT']}")
|
||||
|
|
308
imessage.py
308
imessage.py
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue