A simple Telegram bot that sends interactive 3D molecular structure HTML files to users.
- โจ Interactive inline keyboard with all compounds
- ๐ Sends HTML files directly to users
- ๐ Pagination for easy browsing
- โก Fast and lightweight
- ๐ฏ Simple one-repo, two-branch structure
Repository: molecular-structures-bot
Branch: main (Bot Code)
โโโ bot.py
โโโ compounds.json
โโโ requirements.txt
โโโ .env.example
โโโ .github/workflows/bot.yml
โโโ README.md
Branch: compounds (HTML Files)
โโโ CH4-methane.html
โโโ H2O-water.html
โโโ CO2-carbon-dioxide.html
โโโ ... (all your HTML files)
- Open Telegram and search for @BotFather
- Send
/newbotcommand - Follow instructions to create your bot
- Copy the Bot Token (looks like:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
git clone https://github.com/YOUR_USERNAME/molecular-structures-bot.git
cd molecular-structures-bot- Create a new repository on GitHub
- Upload all files from the
mainbranch - Create a new branch called
compounds - Upload all your HTML files to the
compoundsbranch
Go to your repository โ Settings โ Secrets and variables โ Actions โ New repository secret
Add these secrets:
| Secret Name | Value | Example |
|---|---|---|
BOT_TOKEN |
Your Telegram bot token | 123456789:ABCdefGHI... |
GITHUB_USERNAME |
Your GitHub username | john_doe |
GITHUB_REPO |
Your repository name | molecular-structures-bot |
Edit compounds.json and add your compounds:
{
"compounds": [
{
"formula": "CH4",
"name": "Methane",
"file": "CH4-methane.html"
},
{
"formula": "H2O",
"name": "Water",
"file": "H2O-water.html"
}
]
}- Switch to
compoundsbranch - Upload all your HTML files
- Make sure filenames match exactly with
compounds.json
- Go to Actions tab in your repository
- Click on Run Telegram Bot workflow
- Click Run workflow โ Run workflow
- Bot will start running!
- Go to Railway.app
- Sign up with GitHub
- Click New Project โ Deploy from GitHub repo
- Select your repository
- Add environment variables:
BOT_TOKENGITHUB_USERNAMEGITHUB_REPO
- Deploy! ๐
| Command | Description |
|---|---|
/start |
Show welcome message and compound list |
/help |
Show help message |
/list |
Show all compounds |
- User starts the bot with
/start - Bot shows a list of compounds with inline buttons
- User clicks on any compound (e.g., "CH4 - Methane")
- Bot sends the HTML file
- User downloads and opens in browser
- Interactive 3D molecule appears! ๐
Create your 3D molecule HTML file (e.g., C6H6-benzene.html)
git checkout compounds
git add C6H6-benzene.html
git commit -m "Add benzene molecule"
git push origin compoundsgit checkout mainEdit compounds.json:
{
"formula": "C6H6",
"name": "Benzene",
"file": "C6H6-benzene.html"
}git add compounds.json
git commit -m "Add benzene to compound list"
git push origin mainBot automatically picks up the new compound! Users can now select it.
- Clone the repository
- Create
.envfile (copy from.env.example) - Install dependencies:
pip install -r requirements.txt- Run the bot:
python bot.py- Check if Bot Token is correct
- Make sure GitHub secrets are set properly
- Check GitHub Actions logs for errors
- Verify filename in
compounds.jsonmatches actual file - Check if file exists in
compoundsbranch - Make sure file is accessible (not in subfolder)
- Default timeout is 6 hours
- For 24/7 operation, use Railway or similar service
Use this format for HTML files:
FORMULA-name.html
Examples:
CH4-methane.htmlโH2O-water.htmlโC6H12O6-glucose.htmlโmethane.htmlโ (missing formula)CH4_Methane.htmlโ (use hyphen, not underscore)
When ready for production:
- Go to Railway.app
- Import your GitHub repository
- Add environment variables
- Deploy
- Optional: Disable GitHub Actions workflow
No code changes needed! Same code works on both platforms.
MIT License - Feel free to use and modify!
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For issues or questions:
- Open an issue on GitHub
- Contact: [Your Contact Info]
Created with โค๏ธ for chemistry enthusiasts!
โญ If you find this useful, please star the repository!