Code Monkey home page Code Monkey logo

ptouch_bot's Introduction

P-Touch Telegram bot

I wanted to make my Brother 2430PC accessible to all house users without using a computer.
I used a Raspberry Pi Zero W with Raspberry Pi OS Lite for this job.

Dependencies

Needed packages that were missing from the Pi Zero:

libusb-1.0-0-dev libgd-dev autopoint autoconf git gawk

Printing from Linux

We need to build this utility in oder to print from a linux machine

cd ~
git clone https://mockmoon-cybernetics.ch/cgi/cgit/linux/ptouch-print.git/
cd ptouch-print

Before building, we should fix an error in one of the source files.
src/libptouch.c line 180 change from %ld to %u

Build and Install

./autogen.sh
./configure --prefix=/usr
make
sudo make install

Finally make the USB bus accessible without using sudo

sudo chmod -R 777 /dev/bus/usb

Telegram Bot

I used python-telegram-bot for this job.

cd ~
sudo apt-get install python3-pip
git clone https://github.com/python-telegram-bot/python-telegram-bot.git
cd python-telegram-bot
git submodule update --init --recursive
python3 setup.py install

Add your bot token and allowed user IDs to print_consts.py

Running the Bot

python3 ptouch_bot.py

Startup Service

Create a service file under /etc/systemd/system/ptouch_bot.service:

[Unit]
Description=P-Touch Bot
After=network-online.target
Wants=network-online.target

[Service]
Restart=always
RestartSec=3
ExecStartPre=sudo chmod -R 777 /dev/bus/usb/
ExecStart=python3 /home/pi/ptouch_bot/ptouch_bot.py

[Install]
WantedBy=multi-user.target

Enable the service

sudo systemctl enable ptouch_bot.service

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.