S!ayer on Nostr: I have a question for nostr devs: say I want to create a bot, how do I then get it to ...
I have a question for nostr devs: say I want to create a bot, how do I then get it to post to nostr?
ChatGPT is telling me there's a nostrpy and I can import nostr into python?
e.g.
import time
import random
import nostr
# Initialize Nostr
nostr_client = nostr.Client(private_key="your_private_key")
# Example quotes
quotes = [
"Be yourself; everyone else is already taken. - Oscar Wilde",
"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. - Albert Einstein",
"So many books, so little time. - Frank Zappa"
]
def post_quote():
quote = random.choice(quotes)
nostr_client.send_message(quote)
# Run the bot
while True:
post_quote()
time.sleep(3600) # Post every hour
but I'm working blind here.
Published at
2024-08-07 19:51:48Event JSON
{
"id": "58c3ddf834a42a7b71b62ed38534857d7bf82932969e5b612a0aa2b8b94211a7",
"pubkey": "cdecc31c6d9406e9a7d6b0067412aa661d9d31c8035c3fd65c06301d1cac3b92",
"created_at": 1723060308,
"kind": 1,
"tags": [],
"content": "I have a question for nostr devs: say I want to create a bot, how do I then get it to post to nostr? \n\nChatGPT is telling me there's a nostrpy and I can import nostr into python? \n\ne.g.\n\nimport time\nimport random\nimport nostr\n\n# Initialize Nostr\nnostr_client = nostr.Client(private_key=\"your_private_key\")\n\n# Example quotes\nquotes = [\n \"Be yourself; everyone else is already taken. - Oscar Wilde\",\n \"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. - Albert Einstein\",\n \"So many books, so little time. - Frank Zappa\"\n]\n\ndef post_quote():\n quote = random.choice(quotes)\n nostr_client.send_message(quote)\n\n# Run the bot\nwhile True:\n post_quote()\n time.sleep(3600) # Post every hour\n\n\nbut I'm working blind here. ",
"sig": "4e9d68ba164ca11df4027d4070e691a3e674526531246e912c2d6fb7c3779dead697ff20db0c4a8c7aa26d59737b63c0ce1aa725f8d240b12fadca91ccb177df"
}