From be948b6ca3c86ae238a511b58265f0393e6f35ca Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 9 Feb 2023 11:55:12 +0100 Subject: [PATCH] subscribe --- main.py | 5 +++++ nostr/client/client.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 1657e00..436eaa1 100644 --- a/main.py +++ b/main.py @@ -28,6 +28,11 @@ async def dm(): ) client = NostrClient(privatekey_hex=pk) + if not pk: + print(f"Your private key: {client.private_key.hex()}") + + print(f"Your public key: {client.public_key.hex()}") + # await asyncio.sleep(1) t = threading.Thread( target=client.get_dm, diff --git a/nostr/client/client.py b/nostr/client/client.py index 5517207..5431152 100644 --- a/nostr/client/client.py +++ b/nostr/client/client.py @@ -129,9 +129,10 @@ class NostrClient: break time.sleep(0.1) - async def subscribe(self): + async def subscribe(self, callback_func=None): while True: while self.relay_manager.message_pool.has_events(): event_msg = self.relay_manager.message_pool.get_event() - break + if callback_func: + callback_func(event_msg.event) time.sleep(0.1)