Skip to content

Commit

Permalink
filter for DM
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Feb 13, 2023
1 parent 383f49e commit 2872fe3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 1 addition & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ def callback(event: Event, decrypted_content):

print(f"Your public key: {client.public_key.bech32()}")

# await asyncio.sleep(1)
t = threading.Thread(
target=client.get_dm,
args=(
client.public_key,
callback,
),
args=(client.public_key, callback),
)
t.start()

Expand Down
3 changes: 2 additions & 1 deletion nostr/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ def dm(self, message: str, to_pubkey: PublicKey):
self.private_key.sign_event(dm)
self.relay_manager.publish_event(dm)

def get_dm(self, sender_publickey: PublicKey, callback_func=None):
def get_dm(self, sender_publickey: PublicKey, callback_func=None, filter_kwargs={}):
filters = Filters(
[
Filter(
kinds=[EventKind.ENCRYPTED_DIRECT_MESSAGE],
pubkey_refs=[sender_publickey.hex()],
**filter_kwargs,
)
]
)
Expand Down

0 comments on commit 2872fe3

Please sign in to comment.