A Nostr bot that automatically approves join requests for NIP-72 moderated communities by maintaining a community member list.
This bot monitors a specified relay for join request events (kind 4552) targeting a specific community and automatically adds the requesting users to the community's member list. It maintains a replaceable event (kind 34551) that serves as the community's member roster.
- Listens for Join Requests: The bot subscribes to kind 4552 events that
are tagged with the specified community's
a
tag - Maintains Member List: For each join request, it updates or creates a kind 34551 replaceable event containing the community member list
- Auto-Approval: New members are automatically added to the
p
tags in the member list event
NIP-72 defines moderated communities where:
- Communities are defined by kind 34550 events
- Community posts are tagged with the community's
a
tag - Moderators can approve posts using kind 4550 events
- This bot specifically handles membership management through kind 34551 events
- Deno runtime
- A Nostr private key (nsec format)
- Access to a Nostr relay
- A NIP-72 community identifier
- Clone this repository
- Ensure Deno is installed on your system
- Copy
.env.example
to.env
and configure your environment variables
The bot is configured using environment variables. Create a .env
file in the
project root with the following variables:
RELAY_URL="wss://relay.example.com"
GROUP_ADDR="34550:pubkey:community-identifier"
NSEC="nsec1your-private-key-here"
RELAY_URL
: The relay URL to connect to (required)GROUP_ADDR
: The community'sa
tag identifier in format34550:<pubkey>:<d-identifier>
(required)NSEC
: Your Nostr private key in nsec format (required)
RELAY_URL="wss://relay.chorus.community/"
GROUP_ADDR="34550:932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d:oslo-freedom-forum-2025-mb3ch5ft"
NSEC="nsec1abc123def456..."
deno task start
Or run directly:
deno run -A --env-file main.ts
Run with file watching for automatic restarts during development:
deno task dev
@nostrify/nostrify
: Nostr protocol implementationnostr-tools
: Nostr utilities and key handling
- Private Key Security: Never commit your
.env
file or nsec to version control. The.env
file is already included in.gitignore
for safety - Environment Variables: Store sensitive configuration in environment variables or use secure key management systems in production
- Relay Trust: Only connect to trusted relays
- Community Management: Ensure you have proper authorization to manage the target community
- Rate Limiting: The bot processes requests as they come in; consider implementing rate limiting for high-traffic communities
The bot listens for join request events with:
kind
: 4552 (join request)#a
tag: Matching the specified community identifier
The bot creates/updates member list events with:
kind
: 34551 (community member list)#d
tag: Community identifier#p
tags: List of member public keys
- Only handles automatic approval (no rejection logic)
- Requires the bot operator to be authorized to manage the community
- No built-in duplicate detection (relies on Nostr's replaceable event semantics)
- No member removal functionality
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is in the public domain.