A simple yet powerful Telegram bot that allows users to securely store, edit, list, and retrieve key-value pairs associated with their Telegram chat ID. The bot uses a queue system (via pyqueue_client) to persist user data in a JSON file, making it easy for other applications to process or consume the stored information.
- 🚀 Start the bot and get instructions with
/start - 💾 Store a new key-value pair with
/store - ✏️ Edit an existing key-value pair with
/edit - 📋 List all your stored keys and values with
/list - 🔍 Find a specific key with
/find - 🔒 All data is associated with your Telegram chat ID for privacy
- 📊 Uses queue-based storage for easy integration with other systems
- Users interact with the bot via Telegram commands
- The bot saves key-value pairs (along with the user's chat ID) in a queue using
pyqueue_client - Data is persisted in a JSON file for reliability
- Other applications can process the queue for further actions
User: /start
Bot: Welcome! Available commands:
/store - Store a new key-value pair
/edit - Edit an existing key-value pair
/list - Show all your stored keys and values
/find - Search for a specific key
User: /store
Bot: Please enter the key you want to store:
User: api_key
Bot: Now please enter the value for key 'api_key':
User: sk-1234567890abcdef
Bot: ✅ Key-value pair stored successfully!
Key: api_key
Value: sk-1234567890abcdef
User: /list
Bot: Your stored key-value pairs:
🔑 Key: api_key
📝 Value: sk-1234567890abcdef
➖➖➖➖➖➖
🔑 Key: database_url
📝 Value: postgresql://localhost:5432/mydb
➖➖➖➖➖➖
User: /find
Bot: Please enter the key you want to find:
User: api_key
Bot: Found key-value pair:
🔑 Key: api_key
📝 Value: sk-1234567890abcdef
User: /edit
Bot: Please enter the key you want to edit:
User: api_key
Bot: Now please enter the value for key 'api_key':
User: sk-new1234567890abcdef
Bot: ✅ Key-value pair updated successfully!
Key: api_key
Value: sk-new1234567890abcdef
- Python 3.7+
- A Telegram Bot Token (from @BotFather)
-
Clone the repository:
git clone https://github.com/downlevel/keystorebot cd keystorebot -
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.envfile in the project root:TELEGRAM_BOT_TOKEN=your_bot_token_here QUEUE_FILE_PATH=queue.json
-
Run the bot:
python main.py
keystorebot/
├── main.py # Entry point
├── bot.py # Telegram bot logic and handlers
├── keystore_client.py # KeyStore class for data management
├── config.py # Configuration and environment variables
├── requirements.txt # Python dependencies
├── queue.json # Data storage file (created automatically)
├── .env # Environment variables (create this)
└── README.md # This file
The bot follows a simple but effective architecture:
- Bot Layer (
bot.py): Handles Telegram interactions and user states - Storage Layer (
keystore_client.py): Manages key-value operations - Queue System: Uses
pyqueue_clientfor reliable data persistence - Configuration (
config.py): Centralized settings management
This project is licensed under the MIT License - see the LICENSE file for details.