https://github.com/mqtth3w/library-telegram-bot
A Telegram bot to handle/manage a personal books library database
https://github.com/mqtth3w/library-telegram-bot
books-library books-management books-management-system cloudflare cloudflare-worker d1sql database google google-books-api library library-database library-management-system open-library-api python telegram telegram-bot telegram-bot-api
Last synced: about 2 months ago
JSON representation
A Telegram bot to handle/manage a personal books library database
- Host: GitHub
- URL: https://github.com/mqtth3w/library-telegram-bot
- Owner: Mqtth3w
- License: gpl-3.0
- Created: 2025-03-02T18:14:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-06T21:47:22.000Z (about 1 year ago)
- Last Synced: 2025-03-06T22:28:34.509Z (about 1 year ago)
- Topics: books-library, books-management, books-management-system, cloudflare, cloudflare-worker, d1sql, database, google, google-books-api, library, library-database, library-management-system, open-library-api, python, telegram, telegram-bot, telegram-bot-api
- Language: JavaScript
- Homepage:
- Size: 126 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Library Telegram bot [](https://github.com/Mqtth3w/library-Telegram-bot)
A Telegram bot to handle your personal library.
## How to deploy the bot completely free ([Cloudflare](https://www.cloudflare.com/) based)
It can handle 100k requests for free per day (Cloudflare limits).
Click here to expand the deployment.
The deployment only takes less than 10 minutes.
- Create a new bot on telegram with [@BotFather](https://telegram.me/BotFather). Save the api token for future use.
- Create a Cloudflare account.
- Go to workers & pages then create a new worker so deploy it.
- Click edit so replace the code with the content of [lib_tel_bot.js](./lib_tel_bot.js). Deploy it.
- Click configure worker, go to setting, go to variables.
- Add the variable API_KEY (secret type). Which is the bot api token.
- Add the variable SECRET_TOKEN (secret type). Generate its value through the script [gen_token.py](./gen_token.py). You can also type it with your hands (1-256 characters. Only characters `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed). Save it for future use.
- **Optionally** you can add a variable GBOOKS_API_KEY (secret type), which is a Google API key restricted to the Books API service. It let you do more requests, generally you don't need it unless you plan to do thousands of requests per day.
- Encrypt (set the secrect type!) all variables and save.
- ### DB setup
Follow the instructions in the DB setup [file](./README2.md).
- ### Webhook
Open the following link after substitution to configure webhook.
```
https://api.telegram.org/bot/setWebhook?url=&secret_token=
```
You should see something like {"ok":true,"result":true,"description":"Webhook was set"} then the bot works.
If you filled wrong info or need to update info you can delete webhook and then you can set it again. Open the following link after substitution to delete webhook.
```
https://api.telegram.org/bot/deleteWebhook
```
### 🤌 Try it!
# 📜 User guide
### 😎 Admin
An admin can also run user commands.
- `/add ` adds the book to the DB by taking the data from Google books API or Open Library API. It shows also the added book's data. *A query with also the title has more probability of success*.
- `/del ` removes the book from the DB.
- `/addmanually ;;;;;;;;;;;;;;;` adds the book with all the specified data. Don't use ";" in fileds. Leave empty a field if you don't want to specify it (e.g. ;1234567890123;Hello;;;;;;;;room a, library 3;;;;;).
- `/settitle ` changes the book's title to the specified.
- `/setauthors ` changes the book's authors to the specified.
- `/setpublisher ` changes the book's publisher to the specified.
- `/setdate ` changes the book's publishedDate to the specified.
- `/setpages ` changes the book's pageCount to the specified.
- `/setsnippet ` changes the book's textSnippet to the specified.
- `/setdesc ` changes the book's description to the specified.
- `/setlang ` changes the book's language code (e.g., en, it, ..) to the specified.
- `/setlocation ` changes the book's location to the specified.
- `/setprice ` changes the book's price to the specified.
- `/setthumbnail ` changes the book's thumbnail to the specified.
- `/addfav ` adds the book to the favorites.
- `/delfav ` removes the book from the favorites.
- `/setcatgs ` changes the book's categories to the specified.
### 😊 User
- Send any text message to search for books by title in DB.
- `/show ` shows all the book's data if the book exists in DB.
- `/count` shows the total number of books in DB.
- `/pagecount` shows the total number of pages in DB.
- `/totalvalue` shows the total value (prices' sum) of books in DB.
- `/help` shows a link to this user guide.
- `/searchauthor ` shows books in DB by the author name.
- `/searchpublisher ` shows books in DB by the publisher name.
- `/showfav` shows all favorite books.
- `/searchcatgs ` shows books in DB by the categories.
### 😭 Others
They can do nothing. If you want everyone able to do read only operations remove the users check ("export default" zone).
# 🛠️ To do
- Search books by published date.
- Web interface (mini app).
- A command to show all books.
# 💭 Discussion
For any comment or to request a new feature you can either use the [Discussions](https://github.com/Mqtth3w/library-Telegram-bot/discussions) section or contact me through the [bot](https://t.me/Mqtth3w_support_bot).
# 🫶 Support
Donate to support my projects.
- Crypto & others: Use the command `/support` in the [bot](https://t.me/Mqtth3w_support_bot).
- [Sponsor](https://github.com/sponsors/Mqtth3w).
- [Buy me a pizza](https://buymeacoffee.com/mqtth3w).
- [liberapay](https://liberapay.com/mqtth3w).
# ⭐ Give a Star!
Support this project by giving it a star. Thanks!