A utility telegram bot for the STEER Nepal trip. Provides some admin features for the finance team.
- Submit Claims: Users can submit claims by entering the department, name, claim category, and amount, followed by uploading a receipt photo.
- Check Claim Status: Users can check the status of their claim by providing a claim ID.
- Receipt Storage: Receipts are uploaded to Google Drive, and the claim details are stored in a Google Sheet.
- Submitting proof of payment: Users can use this to submit proof that they have sent money to the account
Before setting up the bot, ensure you have the following:
- Python 3.8+ installed on your machine.
- A Telegram Bot Token. You can create a new bot via BotFather.
- Google Cloud Project with Google Sheets and Google Drive API enabled.
- Pip for installing the required dependencies.
-
Create a Google Cloud Project:
- Go to the Google Cloud Console and create a new project.
-
Enable the Google Sheets API:
- Navigate to the Google Sheets API and click Enable.
-
Create OAuth Credentials:
- Go to the Credentials page.
- Click on Create Credentials > OAuth 2.0 Client IDs.
- Select Desktop App as the application type.
- Download the credentials file (
credentials.json
) and save it in the root directory of the project.
-
Create a Google Sheet:
- Create a new Google Sheet and note its ID (you can find this in the URL of the sheet).
- Share the sheet with the email address generated in the
credentials.json
file (e.g.,your-project@your-project.iam.gserviceaccount.com
) and give it edit access.
- Enable the Google Drive API:
- Go to the Google Drive API and click Enable.
- Create a Google Drive Folder:
- Create a folder in your Google Drive to store the uploaded receipt images.
- Note the folder ID from the URL (the part after
folders/
in the URL).
- Share the Folder:
- Share the folder with the email address from the
credentials.json
file, giving it edit permissions.
- Share the folder with the email address from the
-
Clone the repository:
git clone https://github.com/your-username/nepal-finance.git cd nepal-finance
-
Create a Virtual Environment:
python3 -m venv venv source venv/bin/activate # For Windows use: venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
-
Google API Dependencies: Make sure you have the
credentials.json
file in the root directory, which you generated during the Google API setup.
-
Set Up Environment Variables: Create a
.env
file in the root directory to store your bot token and other important configurations:BOTAPI_KEY="your-telegram-bot-token" SAMPLE_SPREADSHEET_ID="your-google-sheet-id" DRIVE_FOLDER_ID="your-google-drive-folder-id"
-
Obtain OAuth Tokens: When you first run the bot, the system will prompt you to log in with your Google account. This will generate
sheet_token.json
anddrive_token.json
files to authenticate access to Google Sheets and Drive.
-
Run the bot: Once everything is set up, navigate to the src folder and run the bot using:
cd src python telebot.py
-
Authorization:
- When running the bot for the first time, a browser window will pop up, prompting you to log in and authorize the Google Sheets and Drive APIs.
- This will create the
sheet_token.json
anddrive_token.json
files for future sessions.
-
Bot Activation: Once the bot is running, start interacting with it by searching for it in Telegram with the username
@nepalfinancebot
.
NEPAL-FINANCE/
│
├── src/
│ ├── __pycache__/ # Python cache files (auto-generated)
│ ├── drive_connector.py # Module for handling Google Drive API
│ ├── error_handling.py # Error handling utilities
│ ├── telebot.py # Main bot file
│ ├── utils.py # Utility functions for Google Sheets and Drive
│
├── venv/ # Virtual environment (dependencies)
├── .env # Environment variables for bot configuration
├── .gitignore # Git ignore file (to ignore unnecessary files)
├── credentials.json # Google API credentials (for authentication)
├── drive_token.json # Token for Google Drive API (auto-generated after first run)
├── sheet_token.json # Token for Google Sheets API (auto-generated after first run)
├── README.md # Project documentation
├── requirements.txt # Python dependencies
Note: Please contribute with PRs... Code is quite bad atm, sorry.
-
Fork the Repository:
- Navigate to the repository page on GitHub and click the Fork button.
- This will create a copy of the repository under your own GitHub account.
-
Clone Your Fork:
- Clone the forked repository to your local machine using the following command:
git clone https://github.com/your-username/nepal-finance.git cd nepal-finance
- Clone the forked repository to your local machine using the following command:
-
Create a New Branch:
- Create a new branch to work on a specific feature or fix. Make sure to name the branch descriptively so it’s clear what you're working on:
git checkout -b feature/your-feature-name
- Create a new branch to work on a specific feature or fix. Make sure to name the branch descriptively so it’s clear what you're working on:
-
Make Your Changes:
- Implement your feature or bug fix in the newly created branch.
- Commit your changes using clear and concise commit messages:
git add . git commit -m "Add feature/fix description here"
-
Push Your Branch:
- Push the changes to your forked repository on GitHub:
git push origin feature/your-feature-name
- Push the changes to your forked repository on GitHub:
-
Create a Pull Request (PR):
- After pushing your branch, go to your forked repository on GitHub.
- You will see a prompt to create a pull request. Click on that button or go to the Pull Requests tab, then click New Pull Request.
- Compare your branch with the
main
branch of the original repository and submit the pull request with a clear title and description of the changes.
-
Wait for Review:
- If the changes are alright the PR will be merged into the main repository
Before submitting a pull request, please ensure your code follows the project's coding style by using black. This helps to keep the formatting consistent across the codebase.
To format your code with black
, run the following command:
black .