Messe Noire on Nostr: import json import requests import time def post_news(relay_url, private_key, news): ...
import json
import requests
import time
def post_news(relay_url, private_key, news):
# Create a new Nostr note
note = {
"kind": 1,
"created_at": int(time.time()),
"tags": [],
"content": news,
"sig": ""
}
# Sign the note with your private key
# Note: This is a simplified example, you should use a library for this
note["sig"] = sign_note(note, private_key)
# Send the note to the Nostr relay
requests.post(relay_url, json=note)
def sign_note(note, private_key):
# This is a placeholder, replace with actual signing code
return "signed note"
# Replace with your actual relay URL, private key, and news source
relay_url = "wss://relay.damus.io"
private_key = "your_nostr_private_key"
news_source = "https://www.example.com/news.json";
while True:
# Fetch the news from the source
news = requests.get(news_source).text
# Post the news to the Nostr relay
post_news(relay_url, private_key, news)
# Wait for 1 hour before posting again
time.sleep(3600)
esse foi o código gerado pela IA para poder o bot ser criado, agora falta eu tentar realizar alguns testes com ele, porém eu não possuo o cron, pois ele é apenas para linux e macOS assim me disse a IA
import requests
import time
def post_news(relay_url, private_key, news):
# Create a new Nostr note
note = {
"kind": 1,
"created_at": int(time.time()),
"tags": [],
"content": news,
"sig": ""
}
# Sign the note with your private key
# Note: This is a simplified example, you should use a library for this
note["sig"] = sign_note(note, private_key)
# Send the note to the Nostr relay
requests.post(relay_url, json=note)
def sign_note(note, private_key):
# This is a placeholder, replace with actual signing code
return "signed note"
# Replace with your actual relay URL, private key, and news source
relay_url = "wss://relay.damus.io"
private_key = "your_nostr_private_key"
news_source = "https://www.example.com/news.json";
while True:
# Fetch the news from the source
news = requests.get(news_source).text
# Post the news to the Nostr relay
post_news(relay_url, private_key, news)
# Wait for 1 hour before posting again
time.sleep(3600)
esse foi o código gerado pela IA para poder o bot ser criado, agora falta eu tentar realizar alguns testes com ele, porém eu não possuo o cron, pois ele é apenas para linux e macOS assim me disse a IA