{"id":26950643,"url":"https://github.com/zkhan93/printermasterbot","last_synced_at":"2026-05-10T16:46:03.658Z","repository":{"id":81622906,"uuid":"324624753","full_name":"zkhan93/printermasterbot","owner":"zkhan93","description":"Telegram bot that allows users to print documents directly from their Telegram chat.","archived":false,"fork":false,"pushed_at":"2023-06-15T02:00:48.000Z","size":19,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-01-31T18:41:05.635Z","etag":null,"topics":["cups","docker","lp","printing","python","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkhan93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-26T19:50:44.000Z","updated_at":"2024-01-31T18:41:05.636Z","dependencies_parsed_at":null,"dependency_job_id":"d9460fe1-d791-4c04-a045-ff3512da235a","html_url":"https://github.com/zkhan93/printermasterbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkhan93%2Fprintermasterbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkhan93%2Fprintermasterbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkhan93%2Fprintermasterbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkhan93%2Fprintermasterbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkhan93","download_url":"https://codeload.github.com/zkhan93/printermasterbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246910926,"owners_count":20853652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cups","docker","lp","printing","python","telegram-bot"],"created_at":"2025-04-02T23:31:12.661Z","updated_at":"2026-05-10T16:45:58.623Z","avatar_url":"https://github.com/zkhan93.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrinterMasterBot\n\nPrinterMasterBot is a Telegram bot that allows users to send documents or photos directly to a connected printer. It integrates with the CUPS (Common Unix Printing System) to manage print jobs and supports deployment as a system service or Docker container.\n\n---\n\n## Features\n\n- Accepts files or photos via Telegram and sends them to a connected printer.\n- Configurable via environment variables for access control and bot token.\n- Supports USB-connected printers with CUPS integration.\n- Flexible deployment: run as a system service or as a Docker container.\n\n---\n\n## Installation Options\n\n### Option 1: Run as a System Service\n\n#### Prerequisites\n\n1. **Install Required Software**:\n   ```bash\n   sudo apt-get install hplip cups\n   ```\n2. **Configure Your Printer**:\n   - Open the CUPS web interface (`http://localhost:631`).\n   - Add your printer and enable sharing for network printing.\n3. **Install Python and Pipenv**:\n   ```bash\n   sudo apt-get install python3 pipenv\n   ```\n\n#### Steps\n\n1. Clone the repository and navigate to the project directory:\n   ```bash\n   git clone https://github.com/your-repo/printermasterbot.git\n   cd printermasterbot\n   ```\n\n2. Install Python dependencies:\n   ```bash\n   pipenv install\n   ```\n\n3. Configure the environment variables:\n   - Edit the service file `printermasterbot.service` and add your `TOKEN` and `ALLOWED_USERNAMES` environment variables.\n\n4. Install and enable the service:\n   ```bash\n   sudo cp printermasterbot.service /etc/systemd/system/\n   sudo systemctl daemon-reload\n   sudo systemctl enable printermasterbot.service\n   sudo systemctl start printermasterbot.service\n   ```\n\n---\n\n### Option 2: Run as a Docker Container\n\n#### Prerequisites\n\n- **Install Docker**:\n  ```bash\n  sudo apt-get install docker docker-compose\n  ```\n\n- Ensure your printer is configured with CUPS.\n\n#### Build and Run with Docker\n\n1. **Build the Docker Image**:\n   ```bash\n   docker build -t printermasterbot .\n   ```\n\n2. **Run the Docker Container**:\n   ```bash\n   docker run -it --name printermasterbot \\\n     --device=/dev/usb/lp0 \\\n     -v /var/run/cups/cups.sock:/var/run/cups/cups.sock \\\n     -e TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ \\\n     -e ALLOWED_USERNAMES=user1,user2,user3 \\\n     printermasterbot\n   ```\n\n#### Using Docker Compose\n\n1. Create a `docker-compose.yml` file:\n   ```yaml\n   version: \"3.8\"\n   services:\n     printermasterbot:\n       image: printermasterbot\n       container_name: printermasterbot\n       restart: always\n       devices:\n         - /dev/usb/lp0:/dev/usb/lp0\n       volumes:\n         - /var/run/cups/cups.sock:/var/run/cups/cups.sock\n       environment:\n         - TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ\n         - ALLOWED_USERNAMES=user1,user2,user3\n   ```\n\n2. Start the container:\n   ```bash\n   docker-compose up -d\n   ```\n\n---\n\n## Usage\n\n1. Find the bot on Telegram by searching for `@your_bot_username`.\n2. Start the bot with the `/start` command.\n3. Send a document or photo to the bot, and it will send it to the printer.\n4. Use the `/clean` command (restricted to allowed users) to clear old files.\n\n---\n\n## Environment Variables\n\n- **`TOKEN`**: (Required) Your Telegram Bot API token.\n  - Example: `123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ`\n\n- **`ALLOWED_USERNAMES`**: (Optional) A comma-separated list of Telegram usernames allowed to use the bot. If unset, all users can interact with the bot.\n  - Example: `user1,user2,user3`\n\n---\n\n## Notes\n\n- Ensure your printer is powered on and connected before starting the bot.\n- For Docker deployments, make sure to forward USB devices and CUPS sockets to the container.\n- The bot uses the `lp` command to send files to the printer with options like `fit-to-page` and `A4` media.\n\n---\n\n## Troubleshooting\n\n- **Printer not detected**: Check CUPS configuration and ensure the printer is added and shared.\n- **Bot not responding**: Verify your Telegram Bot API token and network connection.\n- **Permission issues**: Ensure the user running the bot has access to the printer and CUPS.\n\nContributions and issues are welcome to improve PrinterMasterBot!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkhan93%2Fprintermasterbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkhan93%2Fprintermasterbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkhan93%2Fprintermasterbot/lists"}