forked from jooray/nostr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slow-post.py
26 lines (20 loc) · 845 Bytes
/
slow-post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import subprocess
import sys
import time
import json
if len(sys.argv) < 2:
print("Error: Not enough arguments provided, I need a relay.")
sys.exit(1)
relay = sys.argv[1]
data = json.loads(sys.stdin.read())
# Execute the binary for each element in the JSON array
for item in data:
# Replace 'binary_path' with the actual path to your binary executable
process = subprocess.Popen(['nak','event', relay], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.stdin.write(json.dumps(item).encode('utf-8')) # Send the item as a JSON string to the process's stdin
process.stdin.flush()
output, error = process.communicate()
# Print the output and error (if any) for debugging purposes
print('Output:', output.decode('utf-8'))
print('Error:', error.decode('utf-8'))
time.sleep(1)