A Telegram bot built with Python and the python-telegram-bot library to provide open educational resources (OER) such as notes, cheatsheets, textbooks, text, and videos. Users can browse resources by category, grade, and subject, while admins can add new resources (files or links) to the database. The bot uses a JSON file for persistent storage.
- Browse Resources: Users can explore educational content categorized by type (e.g., Notes, Textbooks), grade (9th–12th), and subject (English, Math, Biology, Chemistry, Physics).
- Admin Functionality: Authorized admins can add new resources (files or links) via the
/addresourcecommand. - Persistent Storage: Resources are stored in a JSON file (
resources_db.json) for persistence across restarts. - Default Resources: Predefined open educational links are provided when no custom resources are available.
- Interactive Menus: Custom keyboards guide users through the selection process.
- Python 3.7+
- Telegram Bot Token: Obtain a token from BotFather on Telegram.
- Dependencies: Install required Python packages (see Installation).
-
Clone the Repository:
git clone https://github.com/yourusername/oer-bot.git cd oer-bot -
Install Dependencies:
pip install python-telegram-bot
-
Set Up Configuration:
- Open the
oer_bot.pyfile. - Replace the
TOKENplaceholder with your BotFather token:TOKEN = 'your-bot-token-here'
- Replace the
ADMIN_IDSplaceholder with your Telegram user ID:To find your Telegram user ID, messageADMIN_IDS = [your_telegram_user_id]
@userinfoboton Telegram.
- Open the
-
Run the Bot:
python oer_bot.py
-
Start the Bot:
- Send
/startto the bot on Telegram to see the welcome message and main menu.
- Send
-
Browse Resources:
- Select a category (e.g., Notes, Textbooks).
- Choose a grade (9th, 10th, 11th, 12th).
- Pick a subject (English, Math, Biology, Chemistry, Physics).
- The bot will send the resource (file or link) or default open resources if none are added.
-
Admin Commands:
/addresource: Start the process to add a new resource (admin only).- Follow the prompts to select category, grade, subject, and upload a file or send a link.
/listresources: View all added resources (admin only).
-
Navigation:
- Use the "Back" button to return to the previous menu.
- Use "Cancel" during resource addition to abort the process.
oer_bot.py: Main bot script containing all logic.resources_db.json: Persistent storage file for resources (created automatically on first save).
The bot stores resources in the following structure:
{
"notes": {
"9th": {
"Math": "file_id_or_link"
}
},
"cheatsheets": {},
"textbooks": {},
"text": {},
"videos": {}
}- Default resources are provided as links to open educational platforms (e.g., OpenStax, Khan Academy).
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name). - Commit your changes (
git commit -m "Add feature"). - Push to the branch (
git push origin feature-name). - Open a pull request.
- Bot Not Responding: Ensure the token is correct and the bot is running.
- Permission Errors: Verify your Telegram user ID is in
ADMIN_IDSfor admin commands. - File Not Found: The
resources_db.jsonfile is created automatically when a resource is added; no need to create it manually.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with python-telegram-bot.
- Inspired by the need for accessible open educational resources.
- Replace
yourusernamein the clone URL with your actual GitHub username. - Add a
LICENSEfile to your repository if you want to include licensing (e.g., MIT License). - You might want to add screenshots or a demo video in the README to showcase the bot’s functionality.