mirror of
https://github.com/aljazceru/python-nostr.git
synced 2025-12-19 07:14:23 +01:00
update client
This commit is contained in:
8
main.py
8
main.py
@@ -24,7 +24,7 @@ async def dm():
|
|||||||
Callback to trigger when a DM is received.
|
Callback to trigger when a DM is received.
|
||||||
"""
|
"""
|
||||||
print(
|
print(
|
||||||
f"From {event.public_key[:3]}..{event.public_key[-3:]}: {decrypted_content}"
|
f"\nFrom {event.public_key[:3]}..{event.public_key[-3:]}: {decrypted_content}"
|
||||||
)
|
)
|
||||||
|
|
||||||
client = NostrClient(privatekey_hex=pk)
|
client = NostrClient(privatekey_hex=pk)
|
||||||
@@ -45,6 +45,7 @@ async def dm():
|
|||||||
print(f"Subscribing to DMs to {to_pubk_hex}")
|
print(f"Subscribing to DMs to {to_pubk_hex}")
|
||||||
while True:
|
while True:
|
||||||
print_status(client)
|
print_status(client)
|
||||||
|
await asyncio.sleep(1)
|
||||||
msg = input("\nEnter message: ")
|
msg = input("\nEnter message: ")
|
||||||
client.dm(msg, PublicKey(bytes.fromhex(to_pubk_hex)))
|
client.dm(msg, PublicKey(bytes.fromhex(to_pubk_hex)))
|
||||||
|
|
||||||
@@ -57,7 +58,9 @@ async def post():
|
|||||||
"""
|
"""
|
||||||
Callback to trigger when post appers.
|
Callback to trigger when post appers.
|
||||||
"""
|
"""
|
||||||
print(f"From {event.public_key[:3]}..{event.public_key[-3:]}: {event.content}")
|
print(
|
||||||
|
f"\nFrom {event.public_key[:3]}..{event.public_key[-3:]}: {event.content}"
|
||||||
|
)
|
||||||
|
|
||||||
sender_client = NostrClient(privatekey_hex=pk)
|
sender_client = NostrClient(privatekey_hex=pk)
|
||||||
# await asyncio.sleep(1)
|
# await asyncio.sleep(1)
|
||||||
@@ -94,6 +97,7 @@ async def post():
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
print_status(sender_client)
|
print_status(sender_client)
|
||||||
|
await asyncio.sleep(1)
|
||||||
msg = input("\nEnter post: ")
|
msg = input("\nEnter post: ")
|
||||||
sender_client.post(msg)
|
sender_client.post(msg)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user