docs: add comprehensive testing and Discord bot setup guide

Co-authored-by: aider (openai/unsloth/Qwen3-Coder-Next) <aider@aider.chat>
This commit is contained in:
Your Name
2026-02-06 18:02:34 +01:00
parent 7016c3b3ec
commit 28f8676621
5 changed files with 130 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
Format: `!add_receipt "Store Name" YYYY-MM-DD "Product1,quantity,price;Product2,quantity,price"`
### Check Price History
Use the command:

4
!prices Milk Normal file
View File

@@ -0,0 +1,4 @@
### List All Receipts
Use the command:

34
!receipts Normal file
View File

@@ -0,0 +1,34 @@
## Troubleshooting
### Bot doesn't respond to commands
- Make sure MESSAGE CONTENT INTENT is enabled in the Discord Developer Portal
- Check that the bot has the correct permissions in the server
### PDF parsing fails
- Ensure the PDF is text-based (not scanned images)
- Check the PDF file is not corrupted
- Verify pdfplumber is installed correctly
### Database errors
- Delete the `grocery_receipts.db` file to reset the database
- The database will be recreated automatically on next run
### Bot can't connect to Discord
- Verify your bot token is correct
- Check your internet connection
- Ensure the bot has been added to your server with correct permissions
## Expected Output
When a PDF receipt is successfully processed, you should see:
- A confirmation message in Discord: "Receipt 'filename.pdf' processed! Found X items."
- A new entry in the `receipts/` folder
- New entries in the database (visible via `!receipts` command)
## Next Steps
Once the basic functionality is working:
- Try uploading different receipt formats
- Test with various store names and product combinations
- Experiment with the price comparison features

View File

@@ -0,0 +1,33 @@
Alternatively, set the environment variable in your system:
- On Linux/macOS: `export DISCORD_BOT_TOKEN=your_bot_token_here`
- On Windows: `set DISCORD_BOT_TOKEN=your_bot_token_here`
## Step 5: Test the Application
1. Start the bot:
```bash
python app.py
```
2. You should see a message like:
```
YourBotName#1234 has connected to Discord!
```
## Step 6: Test Receipt Upload
1. Open Discord and find your bot in a server where it's added
2. Send a message with a PDF receipt attached
3. The bot should:
- Save the PDF to the `receipts/` folder
- Extract text from the PDF
- Parse the receipt data
- Add it to the database
- Send a confirmation message
## Step 7: Test Commands
### Add a Receipt Manually
Use the command:

53
TESTING_GUIDE.md Normal file
View File

@@ -0,0 +1,53 @@
# Testing Guide: Grocery Receipt Tracker
This guide will help you set up and test the Grocery Receipt Tracker with Discord integration.
## Prerequisites
- Python 3.8 or higher
- Discord account
- Basic understanding of command line operations
## Step 1: Create a Discord Bot
1. Go to the [Discord Developer Portal](https://discord.com/developers/applications)
2. Click "New Application" and give it a name (e.g., "Grocery Receipt Tracker")
3. Navigate to the "Bot" section in the left sidebar
4. Click "Add Bot"
5. Under "Privileged Gateway Intents", enable:
- MESSAGE CONTENT INTENT
- SERVER MEMBERS INTENT
6. Click "Reset Token" and copy your bot token
7. Save the token securely (you'll need it for the application)
## Step 2: Add the Bot to Your Server
1. In the Developer Portal, go to "OAuth2" > "URL Generator"
2. Select these scopes:
- `bot`
- `applications.commands`
3. Under "Bot Permissions", select:
- `Send Messages`
- `Attach Files`
- `Read Message History`
4. Copy the generated URL and open it in your browser
5. Select the server where you want to add the bot
6. Click "Authorize"
## Step 3: Set Up the Project
1. Clone or download the project files
2. Create a virtual environment (recommended):
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
## Step 4: Configure Environment Variables
Create a `.env` file in the project root with your Discord bot token: