Skip to content

luofang34/signal_ipfs_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Signal IPFS Bot

A Docker-based bot that monitors Signal chats for IPFS CIDs and automatically pins them for a configurable duration. When it detects an IPFS CID in a Signal message, it automatically pins and downloads the content.

Features

  • 🤖 Monitors specified Signal chats for IPFS CIDs
  • 📥 Automatically downloads and pins IPFS content
  • ⏱️ Configurable pin duration with auto-cleanup
  • 📊 Real-time monitoring and management
  • 📁 Local file pinning support
  • 🔄 Pin duration extension

Project Structure

signal-ipfs-bot/
├── Dockerfile
├── README.md
├── bot.py                   # Main bot logic
├── docker-compose.yml       # Docker services configuration
├── downloads                # Downloaded files and database
│   └── [downloaded files]
├── ipfs_data                # IPFS node data
├── manage.py                # Management CLI tool
├── pins.db                  # SQLite database for pin tracking
├── requirements.txt         # Python dependencies
└── signal-cli-config        # Signal client configuration

Prerequisites

  • Docker
  • Docker Compose
  • Signal account (for linking the bot)

Quick Start

  1. Clone the repository:
git clone https://github.com/luofang34/signal_ipfs_bot.git && cd signal_ipfs_bot
  1. Start the services:
docker compose up -d
  1. Follow the bot's initialization in logs:
docker compose logs -f bot
  1. Link your Signal device:

The bot will automatically:

  • Configure itself using the linked Signal account
  • Start monitoring for IPFS CIDs
  • Download and pin content as received for the configured duration

Usage

Sending CIDs via Signal

Simply send a message containing an IPFS CID to the monitored chat. Examples:

QmZ4tDuvesekSs4qM5ZBKpXiZGun7S2CYtEZRB3DYXkjGx
bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi

Managing Pins

Use the management script to interact with the system. For environment configuration, see the Configuration section:

  1. Check status of all pins:
docker compose exec bot python manage.py status
  1. Pin a local file:
# Copy file into container
docker cp file.txt signal_ipfs_bot-bot-1:/app/downloads/

# Pin the file
docker compose exec bot python manage.py pin /app/downloads/file.txt
  1. Extend pin duration:
docker compose exec bot python manage.py extend QmZ4tDuvesekSs4qM5ZBKpXiZGun7S2CYtEZRB3DYXkjGx 24
  1. Unpin a file:
docker compose exec bot python manage.py unpin QmZ4tDuvesekSs4qM5ZBKpXiZGun7S2CYtEZRB3DYXkjGx

Accessing Files

Downloaded files are stored in the downloads directory:

# List downloaded files
ls -l downloads/

# Copy file from container (if needed)
docker cp signal_ipfs_bot-bot-1:/app/downloads/QmHash ./

Configuration

The bot uses these environment variables:

SIGNAL_API_URL=http://signal-api:8080
IPFS_API_URL=http://ipfs:5001
DOWNLOAD_DIR=/app/downloads
FETCH_INTERVAL=5             # Message check interval (seconds)
PIN_DURATION=72              # How long to keep pins (hours)

Monitoring

Check service logs:

# All services
docker compose logs -f

# Specific service
docker compose logs -f bot
docker compose logs -f signal-api
docker compose logs -f ipfs

View service status:

docker compose ps

Troubleshooting

For issues with initial setup, refer to the Quick Start section.

  1. Signal Linking Issues:
  • Ensure you use the latest Signal mobile app
  • Try refreshing the QR code by restarting the service
  • Check signal-api logs for any errors
  1. IPFS Connectivity:
# Connect to public IPFS nodes if needed
docker compose exec ipfs ipfs swarm connect /dns4/ipfs.io/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
  1. Bot Issues:
# Check bot logs
docker compose logs bot

# Verify database
sqlite3 downloads/pins.db "SELECT * FROM pins;"

# Check downloaded files
ls -l downloads/
  1. Reset Everything:
docker compose down
rm -rf downloads/* signal-cli-config/* ipfs_data/*
docker compose up -d

Contributing

Feel free to open issues or submit pull requests for improvements. For common issues, check the Troubleshooting section first.

License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors