diff --git "a/!add_receipt \"SuperMarket\" 2023-10-15 \"Milk,2,1.50;Bread,1,2.00;Apples,3,0.80\"" "b/!add_receipt \"SuperMarket\" 2023-10-15 \"Milk,2,1.50;Bread,1,2.00;Apples,3,0.80\"" new file mode 100644 index 0000000..044fb88 --- /dev/null +++ "b/!add_receipt \"SuperMarket\" 2023-10-15 \"Milk,2,1.50;Bread,1,2.00;Apples,3,0.80\"" @@ -0,0 +1,6 @@ + +Format: `!add_receipt "Store Name" YYYY-MM-DD "Product1,quantity,price;Product2,quantity,price"` + +### Check Price History + +Use the command: diff --git a/!prices Milk b/!prices Milk new file mode 100644 index 0000000..113c287 --- /dev/null +++ b/!prices Milk @@ -0,0 +1,4 @@ + +### List All Receipts + +Use the command: diff --git a/!receipts b/!receipts new file mode 100644 index 0000000..1fc7f43 --- /dev/null +++ b/!receipts @@ -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 diff --git a/DISCORD_BOT_TOKEN=your_bot_token_here b/DISCORD_BOT_TOKEN=your_bot_token_here new file mode 100644 index 0000000..b649ba5 --- /dev/null +++ b/DISCORD_BOT_TOKEN=your_bot_token_here @@ -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: diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md new file mode 100644 index 0000000..ca8644b --- /dev/null +++ b/TESTING_GUIDE.md @@ -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: +