forked from coracle/caravel
1.1 KiB
1.1 KiB
pub struct Robot
Robot is a nostr identity which acts on behalf of the application.
Members:
secret: String- a nostr secret key, fromROBOT_SECRETname: String- the name of the bot, fromROBOT_NAMEdescription: String- the description of the bot, fromROBOT_DESCRIPTIONpicture: String- the picture URL for the bot, fromROBOT_PICTUREoutbox_relays: Vec<String>- outbox relay URLs, fromROBOT_OUTBOX_RELAYSindexer_relays: Vec<String>- indexer relay URLs, fromROBOT_INDEXER_RELAYSmessaging_relays: Vec<String>- messaging relay URLs, fromROBOT_MESSAGING_RELAYSclient: nostr_sdk::Client
pub fn new() -> Self
- Reads environment and populates members
- Publishes a
kind 0nostr profile, akind 10002relay list, andkind 10050relay selections usingclient
pub async fn send_dm(&self, recipient: &str, message: &str) -> Result<()>
- Fetches recipient's outbox relays from
indexer_relays(cached) - Fetches recipient's messaging relays from their outbox relays (cached)
- Sends DM to recipient via their messaging relays
- If no outbox/messaging relays are found, return an error