forked from coracle/caravel
1.2 KiB
1.2 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_client: nostr_sdk::Client- used for publishing relay lists and metadata, connects toROBOT_OUTBOX_RELAYSindexer_client: nostr_sdk::Client- used for publishing relay lists, connects toROBOT_INDEXER_RELAYSmessagins_client: nostr_sdk::Client- used for sending and receiving dms, connects toROBOT_MESSAGING_RELAYS
pub fn new() -> Self
- Reads environment and populates members. Relay urls should be split and normalized.
- Publishes a
kind 0nostr profile, akind 10002relay list, andkind 10050relay selections
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