From 80bcf6d0acdf35f082a6765db989ef80100f20fb Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 13 Sep 2020 03:56:28 +0300 Subject: Reorganize Python stuff and add command to create packs Fixes #11 --- README.md | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index c46f787..0d4c421 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,43 @@ A fast and simple Matrix sticker picker widget. Tested on Element Web, Android & ## Discussion Matrix room: [`#maunium:maunium.net`](https://matrix.to/#/#maunium:maunium.net) -## Importing packs from Telegram +## Utility commands +In addition to the sticker picker widget itself, this project includes some +utility scripts you can use to import and create sticker packs. + +To get started, install the dependencies for using the commands: + +0. Make sure you have Python 3.6 or higher. 1. (Optional) Set up a virtual environment. - 1. Create with `virtualenv -p python3 .` - 2. Activate with `source ./bin/activate` -2. Install dependencies with `pip install -r requirements.txt` -3. Run `python3 import.py ` - * On the first run, it'll prompt you to log in to Matrix and Telegram. - * The Matrix URL and access token are stored in `config.json` by default. - * The Telethon session data is stored in `sticker-import.session` by default. - * By default, the pack data will be written to `web/packs/`. - * You can pass as many pack URLs as you want. - * You can re-run the command with the same URLs to update packs. - -If you want to list the URLs of all your saved packs, use `python3 import.py --list`. + 1. Create with `virtualenv -p python3 .venv` + 2. Activate with `source .venv/bin/activate` +2. Install the utility commands and their dependencies with `pip install .` + +### Importing packs from Telegram +To import packs from Telegram, simply run `sticker-import ` with +one or more t.me/addstickers/... URLs. + +If you want to list the URLs of all your saved packs, use `sticker-import --list`. This requires logging in with your account instead of a bot token. +Notes: + +* On the first run, it'll prompt you to log in to Matrix and Telegram. + * The Matrix URL and access token are stored in `config.json` by default. + * The Telethon session data is stored in `sticker-import.session` by default. +* By default, the pack data will be written to `web/packs/`. +* You can pass as many pack URLs as you want. +* You can re-run the command with the same URLs to update packs. + +### Creating your own packs +1. Create a directory with your sticker images. + * The file name (excluding extension) will be used as the caption. + * The directory name will be used as the pack name/ID. +2. Run `sticker-pack `. + * If you want to override the pack displayname, pass `--title `. +3. Copy `/pack.json` to `web/packs/your-pack-name.json`. +4. Add `your-pack-name.json` to the list in `web/packs/index.json`. + ## Enabling the sticker widget 1. Serve everything under `web/` using your webserver of choice. Make sure not to serve the top-level data, as `config.json` and the Telethon session file contain sensitive data. -- cgit v1.2.3