Printing: Allow setting paper size. Documentation enhancements.
This commit is contained in:
parent
5876d8bc5b
commit
b4441964ae
13
README.md
13
README.md
|
@ -4,12 +4,13 @@ This bot is meant to be super easy platform to write Matrix bot functionality
|
||||||
in Python. It uses matrix-nio library https://github.com/poljar/matrix-nio/ for
|
in Python. It uses matrix-nio library https://github.com/poljar/matrix-nio/ for
|
||||||
Matrix communications.
|
Matrix communications.
|
||||||
|
|
||||||
Zero configuration except minimal Matrix account info is needed. Everything else can
|
Zero configuration except Matrix account info is needed. Everything else can
|
||||||
be done with bot commands.
|
be done with bot commands.
|
||||||
|
|
||||||
Type !help in room with this bot running to list active modules.
|
Type !help in room with this bot running to list active modules.
|
||||||
|
|
||||||
If you don't want some modules, just delete the files from modules directory.
|
If you don't want some modules, just delete the files from modules directory or
|
||||||
|
disable them with !bot disable command.
|
||||||
|
|
||||||
End-to-end encryption is currently not supported by bot but should be doable.
|
End-to-end encryption is currently not supported by bot but should be doable.
|
||||||
Bot won't respond to commands in e2ee rooms. PR for enabling e2ee is welcome!
|
Bot won't respond to commands in e2ee rooms. PR for enabling e2ee is welcome!
|
||||||
|
@ -439,6 +440,7 @@ Commands (all can be done by bot owner only):
|
||||||
* !printing list - Lists available printers and their rooms
|
* !printing list - Lists available printers and their rooms
|
||||||
* !printing setroomprinter [printername] - Assignes given printer to this room
|
* !printing setroomprinter [printername] - Assignes given printer to this room
|
||||||
* !printing rmroomprinter - Deletes printer from this room
|
* !printing rmroomprinter - Deletes printer from this room
|
||||||
|
* !printing setpapersize [papersize] - Set global paper size. Default is A4. See printer settings for valid values.
|
||||||
|
|
||||||
The module sends the files to CUPS for printing so please see CUPS documentation
|
The module sends the files to CUPS for printing so please see CUPS documentation
|
||||||
on what works and what doesn't.
|
on what works and what doesn't.
|
||||||
|
@ -452,17 +454,18 @@ This module is disabled by default.
|
||||||
## Bot setup
|
## Bot setup
|
||||||
|
|
||||||
* Create a Matrix user
|
* Create a Matrix user
|
||||||
* Get user's access token - In Riot Web see Settings / Help & about
|
* Log in as the newly created user (easiest is Element Web in private window)
|
||||||
|
* Get user's access token (In Element Web see Settings / Help & about)
|
||||||
|
|
||||||
## Running on host
|
## Running on host
|
||||||
|
|
||||||
Run something like (tested on Ubuntu):
|
Run something like (tested on Ubuntu):
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
sudo apt install python3-pip
|
sudo apt install python3-pip libcups2-dev libatlas-base-dev gcc
|
||||||
sudo pip3 install pipenv
|
sudo pip3 install pipenv
|
||||||
pipenv shell
|
pipenv shell
|
||||||
pipenv install --pre
|
pipenv install --pre (this takes ages, go make a sandwich)
|
||||||
MATRIX_USER="@user:matrix.org" MATRIX_ACCESS_TOKEN="MDAxOGxvYlotofcharacters53CgYAYFgo" MATRIX_SERVER="https://matrix.org" JOIN_ON_INVITE=True BOT_OWNERS=@botowner:matrix.org
|
MATRIX_USER="@user:matrix.org" MATRIX_ACCESS_TOKEN="MDAxOGxvYlotofcharacters53CgYAYFgo" MATRIX_SERVER="https://matrix.org" JOIN_ON_INVITE=True BOT_OWNERS=@botowner:matrix.org
|
||||||
python3 bot.py
|
python3 bot.py
|
||||||
```
|
```
|
||||||
|
|
|
@ -95,6 +95,10 @@ class MatrixModule(BotModule):
|
||||||
bot.save_settings()
|
bot.save_settings()
|
||||||
else:
|
else:
|
||||||
await bot.send_text(room, f'No printer called {printer} in your CUPS.')
|
await bot.send_text(room, f'No printer called {printer} in your CUPS.')
|
||||||
|
if args[0] == 'setpapersize':
|
||||||
|
self.paper_size = args[1]
|
||||||
|
bot.save_settings()
|
||||||
|
await bot.send_text(room, f'Paper size set to {self.paper_size}.')
|
||||||
|
|
||||||
def help(self):
|
def help(self):
|
||||||
return 'Print files from Matrix'
|
return 'Print files from Matrix'
|
||||||
|
@ -102,9 +106,12 @@ class MatrixModule(BotModule):
|
||||||
def get_settings(self):
|
def get_settings(self):
|
||||||
data = super().get_settings()
|
data = super().get_settings()
|
||||||
data["printers"] = self.printers
|
data["printers"] = self.printers
|
||||||
|
data["paper_size"] = self.paper_size
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def set_settings(self, data):
|
def set_settings(self, data):
|
||||||
super().set_settings(data)
|
super().set_settings(data)
|
||||||
if data.get("printers"):
|
if data.get("printers"):
|
||||||
self.printers = data["printers"]
|
self.printers = data["printers"]
|
||||||
|
if data.get("paper_size"):
|
||||||
|
self.paper_size = data["paper_size"]
|
||||||
|
|
Loading…
Reference in New Issue