SimpleNostr: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 40: | Line 40: | ||
encoded = binascii.b2a_base64(s, newline=False) | encoded = binascii.b2a_base64(s, newline=False) | ||
TypeError: a bytes-like object is required, not 'str' | TypeError: a bytes-like object is required, not 'str' | ||
</pre> | |||
= Debug = | |||
<pre> | |||
$ git diff | |||
diff --git a/message.py b/message.py | |||
index 9e88376..d2d2c87 100644 | |||
--- a/message.py | |||
+++ b/message.py | |||
@@ -108,7 +108,7 @@ class Message: | |||
kind = 1 | |||
tags = [] | |||
print(self.message) | |||
- print(base64.b64encode(self.message).decode('utf-8')) | |||
+ print(base64.b64encode(self.message.encode('utf-8')).decode('utf-8')) | |||
ret = { | |||
"id": self.get_id(dm_message, iv).hex(), | |||
"pubkey": pubk, | |||
</pre> | </pre> |
Revision as of 17:23, 9 October 2023
Install
sudo apt install python3-venv pip3 install virtualenv git clone https://github.com/ksfi/simple-nostr.git cd simple-nostr python3 -m venv bobenv source ./bobenv/bin/activate pip3 install websockets secp256k1 bech32 python message.py ... deactivate
Run and error:
python message.py ENTER A RELAY: (default: wss://relay.damus.io) wss://127.0.0.1:7777 wss://127.0.0.1:7777 [msg] OR [msg] // [privkey] // [pubkey] OR q to quit OR enter to watch: test test Traceback (most recent call last): File "/home/admin/projects/nostr/simple-nostr/message.py", line 181, in <module> run() File "/home/admin/projects/nostr/simple-nostr/message.py", line 178, in run asyncio.run(m.sendNote()) File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/home/admin/projects/nostr/simple-nostr/message.py", line 124, in sendNote note = json.dumps(["EVENT", self.to_json(dm_message, iv)], separators=(',', ':'), ensure_ascii=False) File "/home/admin/projects/nostr/simple-nostr/message.py", line 111, in to_json print(base64.b64encode(self.message).decode('utf-8')) File "/usr/lib/python3.9/base64.py", line 58, in b64encode encoded = binascii.b2a_base64(s, newline=False) TypeError: a bytes-like object is required, not 'str'
Debug
$ git diff diff --git a/message.py b/message.py index 9e88376..d2d2c87 100644 --- a/message.py +++ b/message.py @@ -108,7 +108,7 @@ class Message: kind = 1 tags = [] print(self.message) - print(base64.b64encode(self.message).decode('utf-8')) + print(base64.b64encode(self.message.encode('utf-8')).decode('utf-8')) ret = { "id": self.get_id(dm_message, iv).hex(), "pubkey": pubk,